chunk-ZBK444RO.js 308 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755
  1. import{a as Ie,b as Se,c as fe}from"./chunk-5IORCEOD.js";import{a as J}from"./chunk-IMPZ7UGB.js";import{a as xe}from"./chunk-ZJ45HMNY.js";import{b as sn}from"./chunk-LKTE2YWL.js";import{a as We,b as fn}from"./chunk-RELHBJJP.js";import{a as de}from"./chunk-7AR5UXG3.js";import{a as Le}from"./chunk-XKBSMKNP.js";import{b as De,c as ln,d as ke,f as se,g as Oe,n as cn}from"./chunk-K2IDXOCV.js";import{a as T,b as G}from"./chunk-45OWWDV7.js";import{a as M}from"./chunk-JX5O4HI2.js";import{a as ne}from"./chunk-6S43R6PL.js";import{a as c}from"./chunk-ZRLECQ27.js";import{a as A}from"./chunk-FEOWMVRK.js";import{a as an,b as Ge}from"./chunk-CUQT2UK5.js";import{a as H}from"./chunk-CB3KB2D3.js";import{a,c as X}from"./chunk-I46SWINN.js";import{a as N}from"./chunk-LNIYJJXS.js";import{a as h}from"./chunk-4D2ERGZX.js";import{a as q}from"./chunk-EDZQSM3T.js";import{a as x}from"./chunk-PJGSCWXZ.js";import{a as u}from"./chunk-NUC3LT2W.js";var E={_maximumCombinedTextureImageUnits:0,_maximumCubeMapSize:0,_maximumFragmentUniformVectors:0,_maximumTextureImageUnits:0,_maximumRenderbufferSize:0,_maximumTextureSize:0,_maximumVaryingVectors:0,_maximumVertexAttributes:0,_maximumVertexTextureImageUnits:0,_maximumVertexUniformVectors:0,_minimumAliasedLineWidth:0,_maximumAliasedLineWidth:0,_minimumAliasedPointSize:0,_maximumAliasedPointSize:0,_maximumViewportWidth:0,_maximumViewportHeight:0,_maximumTextureFilterAnisotropy:0,_maximumDrawBuffers:0,_maximumColorAttachments:0,_highpFloatSupported:!1,_highpIntSupported:!1,_uniformBufferOffsetAlignment:256,_maxUniformBufferBinding:36,_maxArrayTextureLayers:256};Object.defineProperties(E,{maximumCombinedTextureImageUnits:{get:function(){return E._maximumCombinedTextureImageUnits}},maximumCubeMapSize:{get:function(){return E._maximumCubeMapSize}},maximumFragmentUniformVectors:{get:function(){return E._maximumFragmentUniformVectors}},maximumTextureImageUnits:{get:function(){return E._maximumTextureImageUnits}},maximumRenderbufferSize:{get:function(){return E._maximumRenderbufferSize}},maximumTextureSize:{get:function(){return E._maximumTextureSize}},maximumVaryingVectors:{get:function(){return E._maximumVaryingVectors}},maximumVertexAttributes:{get:function(){return E._maximumVertexAttributes}},maximumVertexTextureImageUnits:{get:function(){return E._maximumVertexTextureImageUnits}},maximumVertexUniformVectors:{get:function(){return E._maximumVertexUniformVectors}},minimumAliasedLineWidth:{get:function(){return E._minimumAliasedLineWidth}},maximumAliasedLineWidth:{get:function(){return E._maximumAliasedLineWidth}},minimumAliasedPointSize:{get:function(){return E._minimumAliasedPointSize}},maximumAliasedPointSize:{get:function(){return E._maximumAliasedPointSize}},maximumViewportWidth:{get:function(){return E._maximumViewportWidth}},maximumViewportHeight:{get:function(){return E._maximumViewportHeight}},maximumTextureFilterAnisotropy:{get:function(){return E._maximumTextureFilterAnisotropy}},maximumDrawBuffers:{get:function(){return E._maximumDrawBuffers}},maximumColorAttachments:{get:function(){return E._maximumColorAttachments}},highpFloatSupported:{get:function(){return E._highpFloatSupported}},highpIntSupported:{get:function(){return E._highpIntSupported}},uniformBufferOffsetAlignment:{get:function(){return E._uniformBufferOffsetAlignment}},maxUniformBufferBinding:{get:function(){return E._maxUniformBufferBinding}},maxArrayTextureLayers:{get:function(){return E._maxArrayTextureLayers}}});var Z=E;function Ii(e,n,t,o){var r=u(n.vertexBuffer),i=u(n.value),l=n.value?n.value.length:n.componentsPerAttribute;if(!r&&!i)throw new x("attribute must have a vertexBuffer or a value.");if(r&&i)throw new x("attribute cannot have both a vertexBuffer and a value. It must have either a vertexBuffer property defining per-vertex data or a value property defining data for all vertices.");if(l!==1&&l!==2&&l!==3&&l!==4)throw i?new x("attribute.value.length must be in the range [1, 4]."):new x("attribute.componentsPerAttribute must be in the range [1, 4].");if(u(n.componentDatatype)&&!M.validate(n.componentDatatype))throw new x("attribute must have a valid componentDatatype or not specify it.");if(u(n.strideInBytes)&&n.strideInBytes>255)throw new x("attribute must have a strideInBytes less than or equal to 255 or not specify it.");if(u(n.instanceDivisor)&&n.instanceDivisor>0&&!o.instancedArrays)throw new x("instanced arrays is not supported");if(u(n.instanceDivisor)&&n.instanceDivisor<0)throw new x("attribute must have an instanceDivisor greater than or equal to zero");if(u(n.instanceDivisor)&&i)throw new x("attribute cannot have have an instanceDivisor if it is not backed by a buffer");if(u(n.instanceDivisor)&&n.instanceDivisor>0&&n.index===0)throw new x("attribute zero cannot have an instanceDivisor greater than 0");var m={index:h(n.index,t),enabled:h(n.enabled,!0),vertexBuffer:n.vertexBuffer,value:i?n.value.slice(0):void 0,componentsPerAttribute:l,componentDatatype:h(n.componentDatatype,M.FLOAT),normalize:h(n.normalize,!1),offsetInBytes:h(n.offsetInBytes,0),strideInBytes:h(n.strideInBytes,0),instanceDivisor:h(n.instanceDivisor,0)};if(r)m.vertexAttrib=function(f){var v=this.index;f.bindBuffer(f.ARRAY_BUFFER,this.vertexBuffer._getBuffer()),f.vertexAttribPointer(v,this.componentsPerAttribute,this.componentDatatype,this.normalize,this.strideInBytes,this.offsetInBytes),f.enableVertexAttribArray(v),this.instanceDivisor>0&&(o.glVertexAttribDivisor(v,this.instanceDivisor),o._vertexAttribDivisors[v]=this.instanceDivisor,o._previousDrawInstanced=!0)},m.disableVertexAttribArray=function(f){f.disableVertexAttribArray(this.index),this.instanceDivisor>0&&o.glVertexAttribDivisor(t,0)};else{switch(m.componentsPerAttribute){case 1:m.vertexAttrib=function(f){f.vertexAttrib1fv(this.index,this.value)};break;case 2:m.vertexAttrib=function(f){f.vertexAttrib2fv(this.index,this.value)};break;case 3:m.vertexAttrib=function(f){f.vertexAttrib3fv(this.index,this.value)};break;case 4:m.vertexAttrib=function(f){f.vertexAttrib4fv(this.index,this.value)};break}m.disableVertexAttribArray=function(f){}}e.push(m)}function mn(e,n,t){for(var o=0;o<n.length;++o){var r=n[o];r.enabled&&r.vertexAttrib(e)}u(t)&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t._getBuffer())}function ie(e){e=h(e,h.EMPTY_OBJECT),q.defined("options.context",e.context),q.defined("options.attributes",e.attributes);var n=e.context,t=n._gl,o=e.attributes,r=e.indexBuffer,i,l=[],m=1,f=!1,v=!1,p=o.length;for(i=0;i<p;++i)Ii(l,o[i],i,n);for(p=l.length,i=0;i<p;++i){var s=l[i];if(u(s.vertexBuffer)&&s.instanceDivisor===0){var d=s.strideInBytes||s.componentsPerAttribute*M.getSizeInBytes(s.componentDatatype);m=s.vertexBuffer.sizeInBytes/d;break}}for(i=0;i<p;++i)l[i].instanceDivisor>0&&(f=!0),u(l[i].value)&&(v=!0);var g={};for(i=0;i<p;++i){var C=l[i].index;if(g[C])throw new x("Index "+C+" is used by more than one attribute.");g[C]=!0}var y;n.vertexArrayObject&&(y=n.glCreateVertexArray(),n.glBindVertexArray(y),mn(t,l,r),n.glBindVertexArray(null)),this._numberOfVertices=m,this._hasInstancedAttributes=f,this._hasConstantAttributes=v,this._context=n,this._gl=t,this._vao=y,this._attributes=l,this._indexBuffer=r}function un(e){return e.values.length/e.componentsPerAttribute}function Ri(e){return M.getSizeInBytes(e.componentDatatype)*e.componentsPerAttribute}function Mi(e){var n,t,o,r=[];for(t in e)e.hasOwnProperty(t)&&u(e[t])&&u(e[t].values)&&(r.push(t),e[t].componentDatatype===M.DOUBLE&&(e[t].componentDatatype=M.FLOAT,e[t].values=M.createTypedArray(M.FLOAT,e[t].values)));var i,l=r.length;if(l>0)for(i=un(e[r[0]]),n=1;n<l;++n){var m=un(e[r[n]]);if(m!==i)throw new ne("Each attribute list must have the same number of vertices. Attribute "+r[n]+" has a different number of vertices ("+m.toString()+") than attribute "+r[0]+" ("+i.toString()+").")}r.sort(function(F,B){return M.getSizeInBytes(e[B].componentDatatype)-M.getSizeInBytes(e[F].componentDatatype)});var f=0,v={};for(n=0;n<l;++n)t=r[n],o=e[t],v[t]=f,f+=Ri(o);if(f>0){var p=M.getSizeInBytes(e[r[0]].componentDatatype),s=f%p;s!==0&&(f+=p-s);var d=i*f,g=new ArrayBuffer(d),C={};for(n=0;n<l;++n){t=r[n];var y=M.getSizeInBytes(e[t].componentDatatype);C[t]={pointer:M.createTypedArray(e[t].componentDatatype,g),index:v[t]/y,strideInComponentType:f/y}}for(n=0;n<i;++n)for(var S=0;S<l;++S){t=r[S],o=e[t];for(var O=o.values,R=C[t],U=R.pointer,V=o.componentsPerAttribute,D=0;D<V;++D)U[R.index+D]=O[n*V+D];R.index+=R.strideInComponentType}return{buffer:g,offsetsInBytes:v,vertexSizeInBytes:f}}}ie.fromGeometry=function(e){e=h(e,h.EMPTY_OBJECT),q.defined("options.context",e.context);var n=e.context,t=h(e.geometry,h.EMPTY_OBJECT),o=h(e.bufferUsage,Se.DYNAMIC_DRAW),r=h(e.attributeLocations,h.EMPTY_OBJECT),i=h(e.interleave,!1),l=e.vertexArrayAttributes,m,f,v,p=u(l)?l:[],s=t.attributes;if(i){var d=Mi(s);if(u(d)){v=fe.createVertexBuffer({context:n,typedArray:d.buffer,usage:o});var g=d.offsetsInBytes,C=d.vertexSizeInBytes;for(m in s)s.hasOwnProperty(m)&&u(s[m])&&(f=s[m],u(f.values)?p.push({index:r[m],vertexBuffer:v,componentDatatype:f.componentDatatype,componentsPerAttribute:f.componentsPerAttribute,normalize:f.normalize,offsetInBytes:g[m],strideInBytes:C}):p.push({index:r[m],value:f.value,componentDatatype:f.componentDatatype,normalize:f.normalize}))}}else for(m in s)if(s.hasOwnProperty(m)&&u(s[m])){f=s[m];var y=f.componentDatatype;y===M.DOUBLE&&(y=M.FLOAT),v=void 0,u(f.values)&&(v=fe.createVertexBuffer({context:n,typedArray:M.createTypedArray(y,f.values),usage:o})),p.push({index:r[m],vertexBuffer:v,value:f.value,componentDatatype:y,componentsPerAttribute:f.componentsPerAttribute,normalize:f.normalize})}var S,O=t.indices;return u(O)&&(cn.computeNumberOfVertices(t)>=N.SIXTY_FOUR_KILOBYTES&&n.elementIndexUint?S=fe.createIndexBuffer({context:n,typedArray:new Uint32Array(O),usage:o,indexDatatype:Le.UNSIGNED_INT}):S=fe.createIndexBuffer({context:n,typedArray:new Uint16Array(O),usage:o,indexDatatype:Le.UNSIGNED_SHORT})),new ie({context:n,attributes:p,indexBuffer:S})};Object.defineProperties(ie.prototype,{numberOfAttributes:{get:function(){return this._attributes.length}},numberOfVertices:{get:function(){return this._numberOfVertices}},indexBuffer:{get:function(){return this._indexBuffer}}});ie.prototype.getAttribute=function(e){return q.defined("index",e),this._attributes[e]};function Pi(e){var n=e._context,t=e._hasInstancedAttributes;if(!(!t&&!n._previousDrawInstanced)){n._previousDrawInstanced=t;var o=n._vertexAttribDivisors,r=e._attributes,i=Z.maximumVertexAttributes,l;if(t){var m=r.length;for(l=0;l<m;++l){var f=r[l];if(f.enabled){var v=f.instanceDivisor,p=f.index;v!==o[p]&&(n.glVertexAttribDivisor(p,v),o[p]=v)}}}else for(l=0;l<i;++l)o[l]>0&&(n.glVertexAttribDivisor(l,0),o[l]=0)}}function Vi(e,n){for(var t=e._attributes,o=t.length,r=0;r<o;++r){var i=t[r];i.enabled&&u(i.value)&&i.vertexAttrib(n)}}ie.prototype._bind=function(){u(this._vao)?(this._context.glBindVertexArray(this._vao),this._context.instancedArrays&&Pi(this),this._hasConstantAttributes&&Vi(this,this._gl)):mn(this._gl,this._attributes,this._indexBuffer)};ie.prototype._unBind=function(){if(u(this._vao))this._context.glBindVertexArray(null);else{for(var e=this._attributes,n=this._gl,t=0;t<e.length;++t){var o=e[t];o.enabled&&o.disableVertexAttribArray(n)}this._indexBuffer&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null)}};ie.prototype.isDestroyed=function(){return!1};ie.prototype.destroy=function(){for(var e=this._attributes,n=0;n<e.length;++n){var t=e[n].vertexBuffer;u(t)&&!t.isDestroyed()&&t.vertexArrayDestroyable&&t.destroy()}var o=this._indexBuffer;return u(o)&&!o.isDestroyed()&&o.vertexArrayDestroyable&&o.destroy(),u(this._vao)&&this._context.glDeleteVertexArray(this._vao),Ie(this)};var dn=ie;function ue(e){e=h(e,h.EMPTY_OBJECT),this._boundingVolume=e.boundingVolume,this._orientedBoundingBox=e.orientedBoundingBox,this._cull=h(e.cull,!0),this._occlude=h(e.occlude,!0),this._modelMatrix=e.modelMatrix,this._primitiveType=h(e.primitiveType,Oe.TRIANGLES),this._vertexArray=e.vertexArray,this._count=e.count,this._offset=h(e.offset,0),this._instanceCount=h(e.instanceCount,0),this._shaderProgram=e.shaderProgram,this._uniformMap=e.uniformMap,this._renderState=e.renderState,this._framebuffer=e.framebuffer,this._pass=e.pass,this._executeInClosestFrustum=h(e.executeInClosestFrustum,!1),this._owner=e.owner,this._debugShowBoundingVolume=h(e.debugShowBoundingVolume,!1),this._debugOverlappingFrustums=0,this._castShadows=h(e.castShadows,!1),this._receiveShadows=h(e.receiveShadows,!1),this._selectCastShadows=!1,this._pickId=e.pickId,this._pickOnly=h(e.pickOnly,!1),this._isViewportQuad=h(e.isViewportQuad,!1),this.dirty=!0,this.lastDirtyTime=0,this.derivedCommands={},this._uniformBuffers=[]}Object.defineProperties(ue.prototype,{boundingVolume:{get:function(){return this._boundingVolume},set:function(e){this._boundingVolume!==e&&(this._boundingVolume=e,this.dirty=!0)}},orientedBoundingBox:{get:function(){return this._orientedBoundingBox},set:function(e){this._orientedBoundingBox!==e&&(this._orientedBoundingBox=e,this.dirty=!0)}},cull:{get:function(){return this._cull},set:function(e){this._cull!==e&&(this._cull=e,this.dirty=!0)}},occlude:{get:function(){return this._occlude},set:function(e){this._occlude!==e&&(this._occlude=e,this.dirty=!0)}},test:{get:function(){return this._test},set:function(e){this._test=e}},modelMatrix:{get:function(){return this._modelMatrix},set:function(e){this._modelMatrix!==e&&(this._modelMatrix=e,this.dirty=!0)}},primitiveType:{get:function(){return this._primitiveType},set:function(e){this._primitiveType!==e&&(this._primitiveType=e,this.dirty=!0)}},vertexArray:{get:function(){return this._vertexArray},set:function(e){this._vertexArray!==e&&(this._vertexArray=e,this.dirty=!0)}},count:{get:function(){return this._count},set:function(e){this._count!==e&&(this._count=e,this.dirty=!0)}},offset:{get:function(){return this._offset},set:function(e){this._offset!==e&&(this._offset=e,this.dirty=!0)}},instanceCount:{get:function(){return this._instanceCount},set:function(e){this._instanceCount!==e&&(this._instanceCount=e,this.dirty=!0)}},shaderProgram:{get:function(){return this._shaderProgram},set:function(e){this._shaderProgram!==e&&(this._shaderProgram=e,this.dirty=!0)}},castShadows:{get:function(){return this._castShadows},set:function(e){this._castShadows!==e&&(this._castShadows=e,this.dirty=!0)}},selectCastShadows:{get:function(){return this._selectCastShadows},set:function(e){this._selectCastShadows!==e&&(this._selectCastShadows=e,this.dirty=!0)}},receiveShadows:{get:function(){return this._receiveShadows},set:function(e){this._receiveShadows!==e&&(this._receiveShadows=e,this.dirty=!0)}},uniformMap:{get:function(){return this._uniformMap},set:function(e){this._uniformMap!==e&&(this._uniformMap=e,this.dirty=!0)}},renderState:{get:function(){return this._renderState},set:function(e){this._renderState!==e&&(this._renderState=e,this.dirty=!0)}},framebuffer:{get:function(){return this._framebuffer},set:function(e){this._framebuffer!==e&&(this._framebuffer=e,this.dirty=!0)}},pass:{get:function(){return this._pass},set:function(e){this._pass!==e&&(this._pass=e,this.dirty=!0)}},executeInClosestFrustum:{get:function(){return this._executeInClosestFrustum},set:function(e){this._executeInClosestFrustum!==e&&(this._executeInClosestFrustum=e,this.dirty=!0)}},owner:{get:function(){return this._owner},set:function(e){this._owner!==e&&(this._owner=e,this.dirty=!0)}},debugShowBoundingVolume:{get:function(){return this._debugShowBoundingVolume},set:function(e){this._debugShowBoundingVolume!==e&&(this._debugShowBoundingVolume=e,this.dirty=!0)}},debugOverlappingFrustums:{get:function(){return this._debugOverlappingFrustums},set:function(e){this._debugOverlappingFrustums!==e&&(this._debugOverlappingFrustums=e,this.dirty=!0)}},pickId:{get:function(){return this._pickId},set:function(e){this._pickId!==e&&(this._pickId=e,this.dirty=!0)}},pickOnly:{get:function(){return this._pickOnly},set:function(e){this._pickOnly!==e&&(this._pickOnly=e,this.dirty=!0)}},isViewportQuad:{get:function(){return this._isViewportQuad}}});ue.prototype.addUniformBuffer=function(e){e.increaseRef(),this._uniformBuffers.push(e)};ue.prototype.removeAllUniformBuffer=function(){if(!!u(this._uniformBuffers)){for(var e=0;e<this._uniformBuffers.length;e++)this._uniformBuffers[e].decreaseRef();this._uniformBuffers=[]}};ue.shallowClone=function(e,n){if(!!u(e))return u(n)||(n=new ue),n._boundingVolume=e._boundingVolume,n._orientedBoundingBox=e._orientedBoundingBox,n._cull=e._cull,n._occlude=e._occlude,n._modelMatrix=e._modelMatrix,n._primitiveType=e._primitiveType,n._vertexArray=e._vertexArray,n._count=e._count,n._offset=e._offset,n._instanceCount=e._instanceCount,n._shaderProgram=e._shaderProgram,n._uniformMap=e._uniformMap,n._uniformBuffers=e._uniformBuffers,n._renderState=e._renderState,n._framebuffer=e._framebuffer,n._pass=e._pass,n._executeInClosestFrustum=e._executeInClosestFrustum,n._owner=e._owner,n._debugShowBoundingVolume=e._debugShowBoundingVolume,n._debugOverlappingFrustums=e._debugOverlappingFrustums,n._castShadows=e._castShadows,n._receiveShadows=e._receiveShadows,n._selectCastShadows=e._selectCastShadows,n._pickId=e._pickId,n._pickOnly=e._pickOnly,n._pointCloudEyeDomeLighting=e._pointCloudEyeDomeLighting,n.dirty=!0,n.lastDirtyTime=0,n};ue.prototype.removeAllFastBundleAndBindGroups=function(){this.bindGroups=void 0,this._fastBundle={}};ue.prototype.execute=function(e,n){e.draw(this,n)};var pn=ue;function Fi(e,n){var t=/#define OUTPUT_DECLARATION/,o=e.split(`
  2. `);if(/#version 300 es/g.test(e))return e;var r=-1,i,l;for(i=0;i<o.length;++i)if(l=o[i],t.test(l)){r=i;break}if(r===-1)throw new x("Could not find a #define OUTPUT_DECLARATION!");var m=[];for(i=0;i<10;i++){var f="gl_FragData\\["+i+"\\]",v="czm_out"+i,p=new RegExp(f,"g");p.test(e)&&(vn(v,m),ae(f,v,o),o.splice(r,0,"layout(location = "+i+") out vec4 "+v+";"),r+=1)}var s="czm_fragColor";Ni("gl_FragColor",o)&&(vn(s,m),ae("gl_FragColor",s,o),o.splice(r,0,"layout(location = 0) out vec4 czm_fragColor;"),r+=1);var d=Ui(m,o),g={};for(i=0;i<o.length;i++){l=o[i];for(var C in d)if(d.hasOwnProperty(C)){var y=new RegExp("(layout)[^]+(out)[^]+("+C+")[^]+","g");y.test(l)&&(g[l]=C)}}for(var S in g)if(g.hasOwnProperty(S)){var O=g[S],R=o.indexOf(S),U=d[O],V=U.length,D;for(D=0;D<V;D++)o.splice(R,0,U[D]);for(R+=V+1,D=V-1;D>=0;D--)o.splice(R,0,"#endif //"+U[D])}var F="#version 300 es",B=!1;for(i=0;i<o.length;i++)/#version/.test(o[i])&&(o[i]=F,B=!0);return B||o.splice(0,0,F),hn("EXT_draw_buffers",o),hn("EXT_frag_depth",o),ae("texture2D","texture",o),ae("texture3D","texture",o),ae("textureCube","texture",o),ae("gl_FragDepthEXT","gl_FragDepth",o),n?ae("varying","in",o):(ae("attribute","in",o),ae("varying","out",o)),Hi(o)}function ae(e,n,t){for(var o="(^|[^\\w])("+e+")($|[^\\w])",r=new RegExp(o,"g"),i=t.length,l=0;l<i;++l){var m=t[l];t[l]=m.replace(r,"$1"+n+"$3")}}function Bi(e,n,t){for(var o=t.length,r=0;r<o;++r){var i=t[r];t[r]=i.replace(e,n)}}function Ni(e,n){for(var t="(^|[^\\w])("+e+")($|[^\\w])",o=new RegExp(t,"g"),r=n.length,i=0;i<r;++i){var l=n[i];if(o.test(l))return!0}return!1}function Hi(e){for(var n="",t=e.length,o=0;o<t;++o)n+=e[o]+`
  3. `;return n}function vn(e,n){n.indexOf(e)===-1&&n.push(e)}function Ui(e,n){for(var t={},o=e.length,r=[],i=0;i<n.length;++i){var l=n[i],m=/(#ifdef|#if)/g.test(l),f=/#else/g.test(l),v=/#endif/g.test(l);if(m)r.push(l);else if(f){var p=r[r.length-1],s=p.replace("ifdef","ifndef");/if/g.test(s)&&(s=s.replace(/(#if\s+)(\S*)([^]*)/,"$1!($2)$3")),r.pop(),r.push(s)}else if(v)r.pop();else if(!/layout/g.test(l))for(var d=0;d<o;++d){var g=e[d];l.indexOf(g)!==-1&&(u(t[g])?t[g]=t[g].filter(function(C){return r.indexOf(C)>=0}):t[g]=r.slice())}}return t}function hn(e,n){var t="#extension\\s+GL_"+e+"\\s+:\\s+[a-zA-Z0-9]+\\s*$";Bi(new RegExp(t,"g"),"",n)}var gn=Fi;var Gi=new a;function _(e){this._size=e.size,this._datatype=e.datatype,this.getValue=e.getValue}var P={};P[c.FLOAT]="float";P[c.FLOAT_VEC2]="vec2";P[c.FLOAT_VEC3]="vec3";P[c.FLOAT_VEC4]="vec4";P[c.INT]="int";P[c.INT_VEC2]="ivec2";P[c.INT_VEC3]="ivec3";P[c.INT_VEC4]="ivec4";P[c.BOOL]="bool";P[c.BOOL_VEC2]="bvec2";P[c.BOOL_VEC3]="bvec3";P[c.BOOL_VEC4]="bvec4";P[c.FLOAT_MAT2]="mat2";P[c.FLOAT_MAT3]="mat3";P[c.FLOAT_MAT4]="mat4";P[c.SAMPLER_2D]="sampler2D";P[c.SAMPLER_CUBE]="samplerCube";_.prototype.getDeclaration=function(e){var n="uniform "+P[this._datatype]+" "+e,t=this._size;return t===1?n+=";":n+="["+t.toString()+"];",n};var ki={czm_viewport:new _({size:1,datatype:c.FLOAT_VEC4,getValue:function(e){return e.viewportCartesian4}}),czm_currentViewportOffset:new _({size:1,datatype:c.FLOAT_VEC4,getValue:function(e){return e.viewportOffset}}),czm_viewportOrthographic:new _({size:1,datatype:c.FLOAT_MAT4,getValue:function(e){return e.viewportOrthographic}}),czm_viewportTransformation:new _({size:1,datatype:c.FLOAT_MAT4,getValue:function(e){return e.viewportTransformation}}),czm_globeDepthTexture:new _({size:1,datatype:c.SAMPLER_2D,getValue:function(e){return e.globeDepthTexture}}),czm_model:new _({size:1,datatype:c.FLOAT_MAT4,getValue:function(e){return e.model}}),czm_inverseModel:new _({size:1,datatype:c.FLOAT_MAT4,getValue:function(e){return e.inverseModel}}),czm_view:new _({size:1,datatype:c.FLOAT_MAT4,getValue:function(e){return e.view}}),czm_view3D:new _({size:1,datatype:c.FLOAT_MAT4,getValue:function(e){return e.view3D}}),czm_viewRotation:new _({size:1,datatype:c.FLOAT_MAT3,getValue:function(e){return e.viewRotation}}),czm_viewRotation3D:new _({size:1,datatype:c.FLOAT_MAT3,getValue:function(e){return e.viewRotation3D}}),czm_inverseView:new _({size:1,datatype:c.FLOAT_MAT4,getValue:function(e){return e.inverseView}}),czm_inverseView3D:new _({size:1,datatype:c.FLOAT_MAT4,getValue:function(e){return e.inverseView3D}}),czm_inverseViewRotation:new _({size:1,datatype:c.FLOAT_MAT3,getValue:function(e){return e.inverseViewRotation}}),czm_inverseViewRotation3D:new _({size:1,datatype:c.FLOAT_MAT3,getValue:function(e){return e.inverseViewRotation3D}}),czm_projection:new _({size:1,datatype:c.FLOAT_MAT4,getValue:function(e){return e.projection}}),czm_inverseProjection:new _({size:1,datatype:c.FLOAT_MAT4,getValue:function(e){return e.inverseProjection}}),czm_infiniteProjection:new _({size:1,datatype:c.FLOAT_MAT4,getValue:function(e){return e.infiniteProjection}}),czm_modelView:new _({size:1,datatype:c.FLOAT_MAT4,getValue:function(e){return e.modelView}}),czm_modelView3D:new _({size:1,datatype:c.FLOAT_MAT4,getValue:function(e){return e.modelView3D}}),czm_modelViewRelativeToEye:new _({size:1,datatype:c.FLOAT_MAT4,getValue:function(e){return e.modelViewRelativeToEye}}),czm_inverseModelView:new _({size:1,datatype:c.FLOAT_MAT4,getValue:function(e){return e.inverseModelView}}),czm_inverseModelView3D:new _({size:1,datatype:c.FLOAT_MAT4,getValue:function(e){return e.inverseModelView3D}}),czm_viewProjection:new _({size:1,datatype:c.FLOAT_MAT4,getValue:function(e){return e.viewProjection}}),czm_inverseViewProjection:new _({size:1,datatype:c.FLOAT_MAT4,getValue:function(e){return e.inverseViewProjection}}),czm_modelViewProjection:new _({size:1,datatype:c.FLOAT_MAT4,getValue:function(e){return e.modelViewProjection}}),czm_inverseModelViewProjection:new _({size:1,datatype:c.FLOAT_MAT4,getValue:function(e){return e.inverseModelViewProjection}}),czm_modelViewProjectionRelativeToEye:new _({size:1,datatype:c.FLOAT_MAT4,getValue:function(e){return e.modelViewProjectionRelativeToEye}}),czm_modelViewInfiniteProjection:new _({size:1,datatype:c.FLOAT_MAT4,getValue:function(e){return e.modelViewInfiniteProjection}}),czm_orthographicIn3D:new _({size:1,datatype:c.FLOAT,getValue:function(e){return e.orthographicIn3D?1:0}}),czm_normal:new _({size:1,datatype:c.FLOAT_MAT3,getValue:function(e){return e.normal}}),czm_normal3D:new _({size:1,datatype:c.FLOAT_MAT3,getValue:function(e){return e.normal3D}}),czm_inverseNormal:new _({size:1,datatype:c.FLOAT_MAT3,getValue:function(e){return e.inverseNormal}}),czm_inverseNormal3D:new _({size:1,datatype:c.FLOAT_MAT3,getValue:function(e){return e.inverseNormal3D}}),czm_eyeHeight2D:new _({size:1,datatype:c.FLOAT_VEC2,getValue:function(e){return e.eyeHeight2D}}),czm_entireFrustum:new _({size:1,datatype:c.FLOAT_VEC2,getValue:function(e){return e.entireFrustum}}),czm_currentFrustum:new _({size:1,datatype:c.FLOAT_VEC2,getValue:function(e){return e.currentFrustum}}),czm_frustumPlanes:new _({size:1,datatype:c.FLOAT_VEC4,getValue:function(e){return e.frustumPlanes}}),czm_farDepthFromNearPlusOne:new _({size:1,datatype:c.FLOAT,getValue:function(e){return e.farDepthFromNearPlusOne}}),czm_log2FarDepthFromNearPlusOne:new _({size:1,datatype:c.FLOAT,getValue:function(e){return e.log2FarDepthFromNearPlusOne}}),czm_oneOverLog2FarDepthFromNearPlusOne:new _({size:1,datatype:c.FLOAT,getValue:function(e){return e.oneOverLog2FarDepthFromNearPlusOne}}),czm_sunPositionWC:new _({size:1,datatype:c.FLOAT_VEC3,getValue:function(e){return e.sunPositionWC}}),czm_sunPositionColumbusView:new _({size:1,datatype:c.FLOAT_VEC3,getValue:function(e){return e.sunPositionColumbusView}}),czm_sunDirectionEC:new _({size:1,datatype:c.FLOAT_VEC3,getValue:function(e){return e.sunDirectionEC}}),czm_sunDirectionWC:new _({size:1,datatype:c.FLOAT_VEC3,getValue:function(e){return e.sunDirectionWC}}),czm_moonDirectionEC:new _({size:1,datatype:c.FLOAT_VEC3,getValue:function(e){return e.moonDirectionEC}}),czm_lightDirectionEC:new _({size:1,datatype:c.FLOAT_VEC3,getValue:function(e){return e.lightDirectionEC}}),czm_lightDirectionWC:new _({size:1,datatype:c.FLOAT_VEC3,getValue:function(e){return e.lightDirectionWC}}),czm_lightColor:new _({size:1,datatype:c.FLOAT_VEC3,getValue:function(e){return e.lightColor}}),czm_lightColorHdr:new _({size:1,datatype:c.FLOAT_VEC3,getValue:function(e){return e.lightColorHdr}}),czm_encodedCameraPositionMCHigh:new _({size:1,datatype:c.FLOAT_VEC3,getValue:function(e){return e.encodedCameraPositionMCHigh}}),czm_encodedCameraPositionMCLow:new _({size:1,datatype:c.FLOAT_VEC3,getValue:function(e){return e.encodedCameraPositionMCLow}}),czm_cameraPositionWC:new _({size:1,datatype:c.FLOAT_VEC3,getValue:function(e){return e._cameraPosition}}),czm_viewerPositionWC:new _({size:1,datatype:c.FLOAT_VEC3,getValue:function(e){return G.getTranslation(e.inverseView,Gi)}}),czm_frameNumber:new _({size:1,datatype:c.FLOAT,getValue:function(e){return e.frameState.frameNumber}}),czm_morphTime:new _({size:1,datatype:c.FLOAT,getValue:function(e){return e.frameState.morphTime}}),czm_sceneMode:new _({size:1,datatype:c.FLOAT,getValue:function(e){return e.frameState.mode}}),czm_pass:new _({size:1,datatype:c.FLOAT,getValue:function(e){return e.pass}}),czm_backgroundColor:new _({size:1,datatype:c.FLOAT_VEC4,getValue:function(e){return e.backgroundColor}}),czm_brdfLut:new _({size:1,datatype:c.SAMPLER_2D,getValue:function(e){return e.brdfLut}}),czm_environmentMap:new _({size:1,datatype:c.SAMPLER_CUBE,getValue:function(e){return e.environmentMap}}),czm_specularEnvironmentMaps:new _({size:1,datatype:c.SAMPLER_2D,getValue:function(e){return e.specularEnvironmentMaps}}),czm_specularEnvironmentMapSize:new _({size:1,datatype:c.FLOAT_VEC2,getValue:function(e){return e.specularEnvironmentMapsDimensions}}),czm_specularEnvironmentMapsMaximumLOD:new _({size:1,datatype:c.FLOAT,getValue:function(e){return e.specularEnvironmentMapsMaximumLOD}}),czm_sphericalHarmonicCoefficients:new _({size:9,datatype:c.FLOAT_VEC3,getValue:function(e){return e.sphericalHarmonicCoefficients}}),czm_SH:new _({size:7,datatype:c.FLOAT_VEC4,getValue:function(e){return e.sphericalHarmonics.shArr}}),czm_temeToPseudoFixed:new _({size:1,datatype:c.FLOAT_MAT3,getValue:function(e){return e.temeToPseudoFixedMatrix}}),czm_pixelRatio:new _({size:1,datatype:c.FLOAT,getValue:function(e){return e.pixelRatio}}),czm_resolutionScale:new _({size:1,datatype:c.FLOAT,getValue:function(e){return e.resolutionScale}}),czm_fogDensity:new _({size:1,datatype:c.FLOAT,getValue:function(e){return e.fogDensity}}),czm_imagerySplitPosition:new _({size:1,datatype:c.FLOAT_VEC2,getValue:function(e){return e.imagerySplitPosition}}),czm_globeSplitPosition:new _({size:1,datatype:c.FLOAT_VEC2,getValue:function(e){return e.globeSplitPosition}}),czm_geometricToleranceOverMeter:new _({size:1,datatype:c.FLOAT,getValue:function(e){return e.geometricToleranceOverMeter}}),czm_minimumDisableDepthTestDistance:new _({size:1,datatype:c.FLOAT,getValue:function(e){return e.minimumDisableDepthTestDistance}}),czm_invertClassificationColor:new _({size:1,datatype:c.FLOAT_VEC4,getValue:function(e){return e.invertClassificationColor}}),czm_gamma:new _({size:1,datatype:c.FLOAT,getValue:function(e){return e.gamma}}),czm_sunColor:new _({size:1,datatype:c.FLOAT_VEC3,getValue:function(e){return e.sunColor}}),czm_globeDepthTextureDim:new _({size:1,datatype:c.FLOAT_VEC2,getValue:function(e){return e.globeDepthTextureDim}}),czm_nonSelDepthTexture:new _({size:1,datatype:c.SAMPLER_2D,getValue:function(e){return e.nonSelDepthTexture}}),czm_maskTexture:new _({size:1,datatype:c.SAMPLER_2D,getValue:function(e){return e.maskTexture}}),czm_hdrEnvMap:new _({size:1,datatype:c.SAMPLER_2D,getValue:function(e){return e.hdrEnvMap}}),czm_toneMappingExposure:new _({size:1,datatype:c.FLOAT,getValue:function(e){return e.toneMappingExposure}}),czm_linearDepthOffset:new _({size:1,datatype:c.FLOAT_VEC2,getValue:function(e){return e.linearDepthOffset}})},Ce=ki;function _n(e){}_n.removeUnuseMacroCode=function(e,n,t){if(!Wi(t))return t;var o=Yi(t),r=[];return Qi(e,n,o,t,r),Ji(t,r)};function Wi(e){return!(e.indexOf("defined",0)>=0||e.indexOf("#if ",0)>=0||e.indexOf("#elif ",0)>=0)}function qi(e,n,t){var o=e.indexOf(`
  4. `,t+n+1),r=t+n+1;return e.substring(r,o)}function xn(e){this.ifIndex=u(e.ifIndex)?e.ifIndex:void 0,this.elseIndex=u(e.elseIndex)?e.elseIndex:void 0,this.endIndex=u(e.endIndex)?e.endIndex:void 0,this.ifChildTokens=[],this.elseChildTokens=[],this.parentToken=u(e.parentToken)?e.parentToken:void 0,this.type=u(e.type)?e.type:void 0}xn.prototype.addChildToken=function(e){u(this.elseIndex)?this.elseChildTokens.push(e):this.ifChildTokens.push(e)};function pe(e,n){this.Key=e,this.String=n,this.StringLength=n.length}pe.isEqual=function(e,n){return e.Key===n.Key};var $={TK_IFDEF:new pe(0,"#ifdef"),TK_IFNEF:new pe(1,"#ifndef"),TK_ELSE:new pe(2,"#else"),TK_END:new pe(3,"#endif")};function Xi(e,n){var t=-1,o=$.TK_IFDEF;for(var r in $){var i=$[r],l=e.indexOf(i.String,n);(t===-1||l>=0&&l<t)&&(t=l,o=i)}return{type:o,findIndex:t}}function Yi(e){for(var n=[],t=0,o=0,r=void 0;t!==-1;){var i=Xi(e,o);if(t=i.findIndex,o=t+i.type.StringLength,t===-1)break;switch(i.type.Key){case $.TK_IFDEF.Key:case $.TK_IFNEF.Key:{var l=new xn({type:i.type,ifIndex:t});u(r)?u(r.endIndex)?(u(r.parentToken)||n.push(l),r=l):(r.addChildToken(l),l.parentToken=r,r=l):(r=l,n.push(l));break}case $.TK_ELSE.Key:{if(!u(r))continue;r.elseIndex=t;break}case $.TK_END.Key:{if(!u(r))continue;r.endIndex=t,u(r.parentToken)&&(r=r.parentToken);break}default:break}}return n}function ji(e,n,t){return pe.isEqual(t,$.TK_IFDEF)&&u(e[n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")])?!0:!!(pe.isEqual(t,$.TK_IFNEF)&&!u(e[n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")]))}function qe(e,n,t,o){var r=0,i=0,l=e.type.StringLength,m=qi(t,l,e.ifIndex),f=ji(n,m,e.type);if(f){u(e.elseIndex)&&(r=e.elseIndex+$.TK_ELSE.StringLength+1,o.push({startIndex:r,endIndex:e.endIndex}));for(var v=0;v<e.ifChildTokens.length;v++)qe(e.ifChildTokens[v],n,t,o)}else{u(e.elseIndex)?o.push({startIndex:e.ifIndex+e.type.StringLength+Zi(t,e.ifIndex,e.type.String)+m.length,endIndex:e.elseIndex}):o.push({startIndex:e.ifIndex,endIndex:e.endIndex+$.TK_END.StringLength});for(var v=0;v<e.elseChildTokens.length;v++)qe(e.elseChildTokens[v],n,t,o)}}function Zi(e,n,t){for(var o=t.length,r=n+o;r<e.length;r++){var i=e.charAt(r);if(i!==" ")break}return r-(n+o)}function Ki(e,n,t){var o=n.defines,r={};if(u(o))for(var i=0;i<o.length;++i){var l=o[i];r[l]=1}if(u(e._sysShaderDefines))for(var i=0;i<e._sysShaderDefines.length;++i){var m=e._sysShaderDefines[i];r[m]=1}for(var f=0,v=0;f!==-1&&(f=t.indexOf("#define ",v),f!==-1);){var p=f+8,s=t.indexOf(`
  5. `,f),d=t.substring(p,s).trim();r[d]=1,v=s}return r}function Qi(e,n,t,o,r){if(t.length!==0)for(var i=Ki(e,n,o),l=0;l<t.length;l++){var m=t[l];qe(m,i,o,r)}}function Ji(e,n){for(var t=e,o=0;o<n.length;o++){var r=n[o];if(r.endIndex-r.startIndex>1){var i=e.substring(r.startIndex,r.endIndex);t=t.replace(i,"")}}return t=t.replace(/(#ifdef|#ifndef|#else|#endif).*/gm,""),t}var Xe=_n;var Cn=`/**
  6. * A built-in GLSL floating-point constant for converting radians to degrees.
  7. *
  8. * @alias czm_degreesPerRadian
  9. * @glslConstant
  10. *
  11. * @see CesiumMath.DEGREES_PER_RADIAN
  12. *
  13. * @example
  14. * // GLSL declaration
  15. * const float czm_degreesPerRadian = ...;
  16. *
  17. * // Example
  18. * float deg = czm_degreesPerRadian * rad;
  19. */
  20. const float czm_degreesPerRadian = 57.29577951308232;
  21. `;var Tn=`/**
  22. * A built-in GLSL vec2 constant for defining the depth range.
  23. * This is a workaround to a bug where IE11 does not implement gl_DepthRange.
  24. *
  25. * @alias czm_depthRange
  26. * @glslConstant
  27. *
  28. * @example
  29. * // GLSL declaration
  30. * float depthRangeNear = czm_depthRange.near;
  31. * float depthRangeFar = czm_depthRange.far;
  32. *
  33. */
  34. const czm_depthRangeStruct czm_depthRange = czm_depthRangeStruct(0.0, 1.0);
  35. `;var yn=`/**
  36. * The reciprocal of the radius of the WGS84 ellipsoid.
  37. *
  38. * @name czm_ellipsoidInverseRadii
  39. * @glslConstant
  40. */
  41. const vec3 czm_ellipsoidInverseRadii = vec3(1.0 / 6378137.0, 1.0 / 6378137.0, 1.0 / 6356752.314245);
  42. `;var zn=`/**
  43. * The radius of the WGS84 ellipsoid.
  44. *
  45. * @name czm_ellipsoidRadii
  46. * @glslConstant
  47. */
  48. const vec3 czm_ellipsoidRadii = vec3(6378137.0, 6378137.0, 6356752.314245);
  49. `;var bn=`/**
  50. * 0.1
  51. *
  52. * @name czm_epsilon1
  53. * @glslConstant
  54. */
  55. const float czm_epsilon1 = 0.1;
  56. `;var wn=`/**
  57. * 0.01
  58. *
  59. * @name czm_epsilon2
  60. * @glslConstant
  61. */
  62. const float czm_epsilon2 = 0.01;
  63. `;var Ln=`/**
  64. * 0.001
  65. *
  66. * @name czm_epsilon3
  67. * @glslConstant
  68. */
  69. const float czm_epsilon3 = 0.001;
  70. `;var Sn=`/**
  71. * 0.0001
  72. *
  73. * @name czm_epsilon4
  74. * @glslConstant
  75. */
  76. const float czm_epsilon4 = 0.0001;
  77. `;var En=`/**
  78. * 0.00001
  79. *
  80. * @name czm_epsilon5
  81. * @glslConstant
  82. */
  83. const float czm_epsilon5 = 0.00001;
  84. `;var An=`/**
  85. * 0.000001
  86. *
  87. * @name czm_epsilon6
  88. * @glslConstant
  89. */
  90. const float czm_epsilon6 = 0.000001;
  91. `;var Dn=`/**
  92. * 0.0000001
  93. *
  94. * @name czm_epsilon7
  95. * @glslConstant
  96. */
  97. const float czm_epsilon7 = 0.0000001;
  98. `;var On=`/**
  99. * DOC_TBA
  100. *
  101. * @name czm_infinity
  102. * @glslConstant
  103. */
  104. const float czm_infinity = 5906376272000.0; // Distance from the Sun to Pluto in meters. TODO: What is best given lowp, mediump, and highp?
  105. `;var In=`/**
  106. * A built-in GLSL floating-point constant for <code>1/pi</code>.
  107. *
  108. * @alias czm_oneOverPi
  109. * @glslConstant
  110. *
  111. * @see CesiumMath.ONE_OVER_PI
  112. *
  113. * @example
  114. * // GLSL declaration
  115. * const float czm_oneOverPi = ...;
  116. *
  117. * // Example
  118. * float pi = 1.0 / czm_oneOverPi;
  119. */
  120. const float czm_oneOverPi = 0.3183098861837907;
  121. `;var Rn=`/**
  122. * A built-in GLSL floating-point constant for <code>1/2pi</code>.
  123. *
  124. * @alias czm_oneOverTwoPi
  125. * @glslConstant
  126. *
  127. * @see CesiumMath.ONE_OVER_TWO_PI
  128. *
  129. * @example
  130. * // GLSL declaration
  131. * const float czm_oneOverTwoPi = ...;
  132. *
  133. * // Example
  134. * float pi = 2.0 * czm_oneOverTwoPi;
  135. */
  136. const float czm_oneOverTwoPi = 0.15915494309189535;
  137. `;var Mn=`/**
  138. * The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE}
  139. *
  140. * @name czm_passCesium3DTile
  141. * @glslConstant
  142. *
  143. * @see czm_pass
  144. */
  145. const float czm_passCesium3DTile = 4.0;
  146. `;var Pn=`/**
  147. * The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE_CLASSIFICATION}
  148. *
  149. * @name czm_passCesium3DTileClassification
  150. * @glslConstant
  151. *
  152. * @see czm_pass
  153. */
  154. const float czm_passCesium3DTileClassification = 5.0;
  155. `;var Vn=`/**
  156. * The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE_CLASSIFICATION_IGNORE_SHOW}
  157. *
  158. * @name czm_passCesium3DTileClassificationIgnoreShow
  159. * @glslConstant
  160. *
  161. * @see czm_pass
  162. */
  163. const float czm_passCesium3DTileClassificationIgnoreShow = 6.0;
  164. `;var Fn=`/**
  165. * The automatic GLSL constant for {@link Pass#CLASSIFICATION}
  166. *
  167. * @name czm_passClassification
  168. * @glslConstant
  169. *
  170. * @see czm_pass
  171. */
  172. const float czm_passClassification = 7.0;
  173. `;var Bn=`/**
  174. * The automatic GLSL constant for {@link Pass#COMPUTE}
  175. *
  176. * @name czm_passCompute
  177. * @glslConstant
  178. *
  179. * @see czm_pass
  180. */
  181. const float czm_passCompute = 1.0;
  182. `;var Nn=`/**
  183. * The automatic GLSL constant for {@link Pass#ENVIRONMENT}
  184. *
  185. * @name czm_passEnvironment
  186. * @glslConstant
  187. *
  188. * @see czm_pass
  189. */
  190. const float czm_passEnvironment = 0.0;
  191. `;var Hn=`/**
  192. * The automatic GLSL constant for {@link Pass#GLOBE}
  193. *
  194. * @name czm_passGlobe
  195. * @glslConstant
  196. *
  197. * @see czm_pass
  198. */
  199. const float czm_passGlobe = 2.0;
  200. `;var Un=`/**
  201. * The automatic GLSL constant for {@link Pass#GROUND}
  202. *
  203. * @name czm_passGround
  204. * @glslConstant
  205. *
  206. * @see czm_pass
  207. */
  208. const float czm_passGround = 4.0;
  209. `;var Gn=`/**
  210. * The automatic GLSL constant for {@link Pass#OPAQUE}
  211. *
  212. * @name czm_passOpaque
  213. * @glslConstant
  214. *
  215. * @see czm_pass
  216. */
  217. const float czm_passOpaque = 12.0;
  218. `;var kn=`/**
  219. * The automatic GLSL constant for {@link Pass#OVERLAY}
  220. *
  221. * @name czm_passOverlay
  222. * @glslConstant
  223. *
  224. * @see czm_pass
  225. */
  226. const float czm_passOverlay = 20.0;`;var Wn=`/**
  227. * The automatic GLSL constant for {@link Pass#TERRAIN_CLASSIFICATION}
  228. *
  229. * @name czm_passTerrainClassification
  230. * @glslConstant
  231. *
  232. * @see czm_pass
  233. */
  234. const float czm_passTerrainClassification = 3.0;
  235. `;var qn=`/**
  236. * The automatic GLSL constant for {@link Pass#TRANSLUCENT}
  237. *
  238. * @name czm_passTranslucent
  239. * @glslConstant
  240. *
  241. * @see czm_pass
  242. */
  243. const float czm_passTranslucent = 18.0;`;var Xn=`/**
  244. * A built-in GLSL floating-point constant for <code>Math.PI</code>.
  245. *
  246. * @alias czm_pi
  247. * @glslConstant
  248. *
  249. * @see CesiumMath.PI
  250. *
  251. * @example
  252. * // GLSL declaration
  253. * const float czm_pi = ...;
  254. *
  255. * // Example
  256. * float twoPi = 2.0 * czm_pi;
  257. */
  258. const float czm_pi = 3.141592653589793;
  259. `;var Yn=`/**
  260. * A built-in GLSL floating-point constant for <code>pi/4</code>.
  261. *
  262. * @alias czm_piOverFour
  263. * @glslConstant
  264. *
  265. * @see CesiumMath.PI_OVER_FOUR
  266. *
  267. * @example
  268. * // GLSL declaration
  269. * const float czm_piOverFour = ...;
  270. *
  271. * // Example
  272. * float pi = 4.0 * czm_piOverFour;
  273. */
  274. const float czm_piOverFour = 0.7853981633974483;
  275. `;var jn=`/**
  276. * A built-in GLSL floating-point constant for <code>pi/6</code>.
  277. *
  278. * @alias czm_piOverSix
  279. * @glslConstant
  280. *
  281. * @see CesiumMath.PI_OVER_SIX
  282. *
  283. * @example
  284. * // GLSL declaration
  285. * const float czm_piOverSix = ...;
  286. *
  287. * // Example
  288. * float pi = 6.0 * czm_piOverSix;
  289. */
  290. const float czm_piOverSix = 0.5235987755982988;
  291. `;var Zn=`/**
  292. * A built-in GLSL floating-point constant for <code>pi/3</code>.
  293. *
  294. * @alias czm_piOverThree
  295. * @glslConstant
  296. *
  297. * @see CesiumMath.PI_OVER_THREE
  298. *
  299. * @example
  300. * // GLSL declaration
  301. * const float czm_piOverThree = ...;
  302. *
  303. * // Example
  304. * float pi = 3.0 * czm_piOverThree;
  305. */
  306. const float czm_piOverThree = 1.0471975511965976;
  307. `;var Kn=`/**
  308. * A built-in GLSL floating-point constant for <code>pi/2</code>.
  309. *
  310. * @alias czm_piOverTwo
  311. * @glslConstant
  312. *
  313. * @see CesiumMath.PI_OVER_TWO
  314. *
  315. * @example
  316. * // GLSL declaration
  317. * const float czm_piOverTwo = ...;
  318. *
  319. * // Example
  320. * float pi = 2.0 * czm_piOverTwo;
  321. */
  322. const float czm_piOverTwo = 1.5707963267948966;
  323. `;var Qn=`/**
  324. * A built-in GLSL floating-point constant for converting degrees to radians.
  325. *
  326. * @alias czm_radiansPerDegree
  327. * @glslConstant
  328. *
  329. * @see CesiumMath.RADIANS_PER_DEGREE
  330. *
  331. * @example
  332. * // GLSL declaration
  333. * const float czm_radiansPerDegree = ...;
  334. *
  335. * // Example
  336. * float rad = czm_radiansPerDegree * deg;
  337. */
  338. const float czm_radiansPerDegree = 0.017453292519943295;
  339. `;var Jn=`/**
  340. * The constant identifier for the 2D {@link SceneMode}
  341. *
  342. * @name czm_sceneMode2D
  343. * @glslConstant
  344. * @see czm_sceneMode
  345. * @see czm_sceneModeColumbusView
  346. * @see czm_sceneMode3D
  347. * @see czm_sceneModeMorphing
  348. */
  349. const float czm_sceneMode2D = 2.0;
  350. `;var $n=`/**
  351. * The constant identifier for the 3D {@link SceneMode}
  352. *
  353. * @name czm_sceneMode3D
  354. * @glslConstant
  355. * @see czm_sceneMode
  356. * @see czm_sceneMode2D
  357. * @see czm_sceneModeColumbusView
  358. * @see czm_sceneModeMorphing
  359. */
  360. const float czm_sceneMode3D = 3.0;
  361. `;var et=`/**
  362. * The constant identifier for the Columbus View {@link SceneMode}
  363. *
  364. * @name czm_sceneModeColumbusView
  365. * @glslConstant
  366. * @see czm_sceneMode
  367. * @see czm_sceneMode2D
  368. * @see czm_sceneMode3D
  369. * @see czm_sceneModeMorphing
  370. */
  371. const float czm_sceneModeColumbusView = 1.0;
  372. `;var nt=`/**
  373. * The constant identifier for the Morphing {@link SceneMode}
  374. *
  375. * @name czm_sceneModeMorphing
  376. * @glslConstant
  377. * @see czm_sceneMode
  378. * @see czm_sceneMode2D
  379. * @see czm_sceneModeColumbusView
  380. * @see czm_sceneMode3D
  381. */
  382. const float czm_sceneModeMorphing = 0.0;
  383. `;var tt=`/**
  384. * A built-in GLSL floating-point constant for one solar radius.
  385. *
  386. * @alias czm_solarRadius
  387. * @glslConstant
  388. *
  389. * @see CesiumMath.SOLAR_RADIUS
  390. *
  391. * @example
  392. * // GLSL declaration
  393. * const float czm_solarRadius = ...;
  394. */
  395. const float czm_solarRadius = 695500000.0;
  396. `;var ot=`/**
  397. * A built-in GLSL floating-point constant for <code>3pi/2</code>.
  398. *
  399. * @alias czm_threePiOver2
  400. * @glslConstant
  401. *
  402. * @see CesiumMath.THREE_PI_OVER_TWO
  403. *
  404. * @example
  405. * // GLSL declaration
  406. * const float czm_threePiOver2 = ...;
  407. *
  408. * // Example
  409. * float pi = (2.0 / 3.0) * czm_threePiOver2;
  410. */
  411. const float czm_threePiOver2 = 4.71238898038469;
  412. `;var rt=`/**
  413. * A built-in GLSL floating-point constant for <code>2pi</code>.
  414. *
  415. * @alias czm_twoPi
  416. * @glslConstant
  417. *
  418. * @see CesiumMath.TWO_PI
  419. *
  420. * @example
  421. * // GLSL declaration
  422. * const float czm_twoPi = ...;
  423. *
  424. * // Example
  425. * float pi = czm_twoPi / 2.0;
  426. */
  427. const float czm_twoPi = 6.283185307179586;
  428. `;var it=`/**
  429. * The maximum latitude, in radians, both North and South, supported by a Web Mercator
  430. * (EPSG:3857) projection. Technically, the Mercator projection is defined
  431. * for any latitude up to (but not including) 90 degrees, but it makes sense
  432. * to cut it off sooner because it grows exponentially with increasing latitude.
  433. * The logic behind this particular cutoff value, which is the one used by
  434. * Google Maps, Bing Maps, and Esri, is that it makes the projection
  435. * square. That is, the rectangle is equal in the X and Y directions.
  436. *
  437. * The constant value is computed as follows:
  438. * czm_pi * 0.5 - (2.0 * atan(exp(-czm_pi)))
  439. *
  440. * @name czm_webMercatorMaxLatitude
  441. * @glslConstant
  442. */
  443. const float czm_webMercatorMaxLatitude = 1.4844222297453324;
  444. `;var at=`/**
  445. * @name czm_depthRangeStruct
  446. * @glslStruct
  447. */
  448. struct czm_depthRangeStruct
  449. {
  450. float near;
  451. float far;
  452. };
  453. `;var lt=`/** DOC_TBA
  454. *
  455. * @name czm_ellipsoid
  456. * @glslStruct
  457. */
  458. struct czm_ellipsoid
  459. {
  460. vec3 center;
  461. vec3 radii;
  462. vec3 inverseRadii;
  463. vec3 inverseRadiiSquared;
  464. };
  465. `;var ct=`/**
  466. * Holds material information that can be used for lighting. Returned by all czm_getMaterial functions.
  467. *
  468. * @name czm_material
  469. * @glslStruct
  470. *
  471. * @property {vec3} diffuse Incoming light that scatters evenly in all directions.
  472. * @property {float} specular Intensity of incoming light reflecting in a single direction.
  473. * @property {float} shininess The sharpness of the specular reflection. Higher values create a smaller, more focused specular highlight.
  474. * @property {vec3} normal Surface's normal in eye coordinates. It is used for effects such as normal mapping. The default is the surface's unmodified normal.
  475. * @property {vec3} emission Light emitted by the material equally in all directions. The default is vec3(0.0), which emits no light.
  476. * @property {float} alpha Opacity of this material. 0.0 is completely transparent; 1.0 is completely opaque.
  477. */
  478. struct czm_material
  479. {
  480. vec3 diffuse;
  481. float specular;
  482. float shininess;
  483. vec3 normal;
  484. vec3 emission;
  485. float alpha;
  486. };
  487. `;var st=`/**
  488. * Used as input to every material's czm_getMaterial function.
  489. *
  490. * @name czm_materialInput
  491. * @glslStruct
  492. *
  493. * @property {float} s 1D texture coordinates.
  494. * @property {vec2} st 2D texture coordinates.
  495. * @property {vec3} str 3D texture coordinates.
  496. * @property {vec3} normalEC Unperturbed surface normal in eye coordinates.
  497. * @property {mat3} tangentToEyeMatrix Matrix for converting a tangent space normal to eye space.
  498. * @property {vec3} positionToEyeEC Vector from the fragment to the eye in eye coordinates. The magnitude is the distance in meters from the fragment to the eye.
  499. * @property {float} height The height of the terrain in meters above or below the WGS84 ellipsoid. Only available for globe materials.
  500. * @property {float} slope The slope of the terrain normalized from 0 to 1. 0 is completely vertical, 1 is completely flat. Only available for globe materials.
  501. */
  502. struct czm_materialInput
  503. {
  504. float s;
  505. vec2 st;
  506. vec3 str;
  507. vec3 normalEC;
  508. mat3 tangentToEyeMatrix;
  509. vec3 positionToEyeEC;
  510. float height;
  511. float slope;
  512. };
  513. `;var ft=`/**
  514. * DOC_TBA
  515. *
  516. * @name czm_ray
  517. * @glslStruct
  518. */
  519. struct czm_ray
  520. {
  521. vec3 origin;
  522. vec3 direction;
  523. };
  524. `;var ut=`/**
  525. * DOC_TBA
  526. *
  527. * @name czm_raySegment
  528. * @glslStruct
  529. */
  530. struct czm_raySegment
  531. {
  532. float start;
  533. float stop;
  534. };
  535. /**
  536. * DOC_TBA
  537. *
  538. * @name czm_emptyRaySegment
  539. * @glslConstant
  540. */
  541. const czm_raySegment czm_emptyRaySegment = czm_raySegment(-czm_infinity, -czm_infinity);
  542. /**
  543. * DOC_TBA
  544. *
  545. * @name czm_fullRaySegment
  546. * @glslConstant
  547. */
  548. const czm_raySegment czm_fullRaySegment = czm_raySegment(0.0, czm_infinity);
  549. `;var mt=`struct czm_s3mMaterialInput
  550. {
  551. vec4 ambientColor;
  552. vec4 diffuseColor;
  553. vec4 ambientLightColor;
  554. vec4 sunLightColor;
  555. mat4 texMatrix;
  556. float texture0Width;
  557. float texture1Width;
  558. vec3 sunDirectionEC;
  559. float sunLightON;
  560. vec3 normalWorld;
  561. vec3 normalGround;
  562. vec3 positionWorld;
  563. vec3 sunDirectionWC;
  564. vec4 surfaceAlbedo;
  565. };
  566. `;var dt=`struct czm_shadowParameters
  567. {
  568. #ifdef USE_CUBE_MAP_SHADOW
  569. vec3 texCoords;
  570. #else
  571. vec2 texCoords;
  572. #endif
  573. float depthBias;
  574. float depth;
  575. float nDotL;
  576. vec2 texelStepSize;
  577. float normalShadingSmooth;
  578. float darkness;
  579. };
  580. `;var pt=`// See:
  581. vec3 czm_acesTonemapping(vec3 color) {
  582. float g = 0.985;
  583. float a = 0.065;
  584. float b = 0.0001;
  585. float c = 0.433;
  586. float d = 0.238;
  587. color = (color * (color + a) - b) / (color * (g * color + c) + d);
  588. color = clamp(color, 0.0, 1.0);
  589. return color;
  590. }
  591. `;var vt=`uniform float uBrightness;
  592. uniform float uContrast;
  593. uniform float uHue;
  594. uniform float uSaturation;
  595. uniform float uOneOverGamma;
  596. vec3 czm_adjustColor(vec3 inputColor)
  597. {
  598. vec3 outputColor = inputColor;
  599. outputColor.rgb = mix(vec3(0.0), outputColor.rgb, uBrightness);
  600. outputColor.rgb = mix(vec3(0.5), outputColor.rgb, uContrast);
  601. outputColor.rgb = czm_hue(outputColor.rgb, uHue);
  602. outputColor.rgb = clamp(outputColor.rgb, 0.0, 1.0);
  603. outputColor.rgb = czm_saturation(outputColor.rgb, uSaturation);
  604. outputColor.rgb = pow(outputColor.rgb, vec3(uOneOverGamma));
  605. return outputColor;
  606. }`;var ht=`/**
  607. * @private
  608. */
  609. float czm_alphaWeight(float a)
  610. {
  611. float z = (gl_FragCoord.z - czm_viewportTransformation[3][2]) / czm_viewportTransformation[2][2];
  612. // See Weighted Blended Order-Independent Transparency for examples of different weighting functions:
  613. return pow(a + 0.01, 4.0) + max(1e-2, min(3.0 * 1e3, 0.003 / (1e-5 + pow(abs(z) / 200.0, 4.0))));
  614. }
  615. `;var gt=`/**
  616. * Procedural anti-aliasing by blurring two colors that meet at a sharp edge.
  617. *
  618. * @name czm_antialias
  619. * @glslFunction
  620. *
  621. * @param {vec4} color1 The color on one side of the edge.
  622. * @param {vec4} color2 The color on the other side of the edge.
  623. * @param {vec4} currentcolor The current color, either <code>color1</code> or <code>color2</code>.
  624. * @param {float} dist The distance to the edge in texture coordinates.
  625. * @param {float} [fuzzFactor=0.1] Controls the blurriness between the two colors.
  626. * @returns {vec4} The anti-aliased color.
  627. *
  628. * @example
  629. * // GLSL declarations
  630. * vec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist, float fuzzFactor);
  631. * vec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist);
  632. *
  633. * // get the color for a material that has a sharp edge at the line y = 0.5 in texture space
  634. * float dist = abs(textureCoordinates.t - 0.5);
  635. * vec4 currentColor = mix(bottomColor, topColor, step(0.5, textureCoordinates.t));
  636. * vec4 color = czm_antialias(bottomColor, topColor, currentColor, dist, 0.1);
  637. */
  638. vec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist, float fuzzFactor)
  639. {
  640. float val1 = clamp(dist / fuzzFactor, 0.0, 1.0);
  641. float val2 = clamp((dist - 0.5) / fuzzFactor, 0.0, 1.0);
  642. val1 = val1 * (1.0 - val2);
  643. val1 = val1 * val1 * (3.0 - (2.0 * val1));
  644. val1 = pow(val1, 0.5); //makes the transition nicer
  645. vec4 midColor = (color1 + color2) * 0.5;
  646. return mix(midColor, currentColor, val1);
  647. }
  648. vec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist)
  649. {
  650. return czm_antialias(color1, color2, currentColor, dist, 0.1);
  651. }
  652. `;var _t=`/**
  653. * Approximately computes spherical coordinates given a normal.
  654. * Uses approximate inverse trigonometry for speed and consistency,
  655. * since inverse trigonometry can differ from vendor-to-vendor and when compared with the CPU.
  656. *
  657. * @name czm_approximateSphericalCoordinates
  658. * @glslFunction
  659. *
  660. * @param {vec3} normal arbitrary-length normal.
  661. *
  662. * @returns {vec2} Approximate latitude and longitude spherical coordinates.
  663. */
  664. vec2 czm_approximateSphericalCoordinates(vec3 normal) {
  665. // Project into plane with vertical for latitude
  666. float latitudeApproximation = czm_fastApproximateAtan(sqrt(normal.x * normal.x + normal.y * normal.y), normal.z);
  667. float longitudeApproximation = czm_fastApproximateAtan(normal.x, normal.y);
  668. return vec2(latitudeApproximation, longitudeApproximation);
  669. }
  670. `;var xt=`/**
  671. * Branchless ternary operator to be used when it's inexpensive to explicitly
  672. * evaluate both possibilities for a float expression.
  673. *
  674. * @name czm_branchFreeTernary
  675. * @glslFunction
  676. *
  677. * @param {bool} comparison A comparison statement
  678. * @param {float} a Value to return if the comparison is true.
  679. * @param {float} b Value to return if the comparison is false.
  680. *
  681. * @returns {float} equivalent of comparison ? a : b
  682. */
  683. float czm_branchFreeTernary(bool comparison, float a, float b) {
  684. float useA = float(comparison);
  685. return a * useA + b * (1.0 - useA);
  686. }
  687. /**
  688. * Branchless ternary operator to be used when it's inexpensive to explicitly
  689. * evaluate both possibilities for a vec2 expression.
  690. *
  691. * @name czm_branchFreeTernary
  692. * @glslFunction
  693. *
  694. * @param {bool} comparison A comparison statement
  695. * @param {vec2} a Value to return if the comparison is true.
  696. * @param {vec2} b Value to return if the comparison is false.
  697. *
  698. * @returns {vec2} equivalent of comparison ? a : b
  699. */
  700. vec2 czm_branchFreeTernary(bool comparison, vec2 a, vec2 b) {
  701. float useA = float(comparison);
  702. return a * useA + b * (1.0 - useA);
  703. }
  704. /**
  705. * Branchless ternary operator to be used when it's inexpensive to explicitly
  706. * evaluate both possibilities for a vec3 expression.
  707. *
  708. * @name czm_branchFreeTernary
  709. * @glslFunction
  710. *
  711. * @param {bool} comparison A comparison statement
  712. * @param {vec3} a Value to return if the comparison is true.
  713. * @param {vec3} b Value to return if the comparison is false.
  714. *
  715. * @returns {vec3} equivalent of comparison ? a : b
  716. */
  717. vec3 czm_branchFreeTernary(bool comparison, vec3 a, vec3 b) {
  718. float useA = float(comparison);
  719. return a * useA + b * (1.0 - useA);
  720. }
  721. /**
  722. * Branchless ternary operator to be used when it's inexpensive to explicitly
  723. * evaluate both possibilities for a vec4 expression.
  724. *
  725. * @name czm_branchFreeTernary
  726. * @glslFunction
  727. *
  728. * @param {bool} comparison A comparison statement
  729. * @param {vec3} a Value to return if the comparison is true.
  730. * @param {vec3} b Value to return if the comparison is false.
  731. *
  732. * @returns {vec3} equivalent of comparison ? a : b
  733. */
  734. vec4 czm_branchFreeTernary(bool comparison, vec4 a, vec4 b) {
  735. float useA = float(comparison);
  736. return a * useA + b * (1.0 - useA);
  737. }
  738. `;var Ct=`
  739. vec4 czm_cascadeColor(vec4 weights)
  740. {
  741. return vec4(1.0, 0.0, 0.0, 1.0) * weights.x +
  742. vec4(0.0, 1.0, 0.0, 1.0) * weights.y +
  743. vec4(0.0, 0.0, 1.0, 1.0) * weights.z +
  744. vec4(1.0, 0.0, 1.0, 1.0) * weights.w;
  745. }
  746. `;var Tt=`
  747. uniform vec4 shadowMap_cascadeDistances;
  748. float czm_cascadeDistance(vec4 weights)
  749. {
  750. return dot(shadowMap_cascadeDistances, weights);
  751. }
  752. `;var yt=`
  753. uniform mat4 shadowMap_cascadeMatrices[4];
  754. mat4 czm_cascadeMatrix(vec4 weights)
  755. {
  756. return shadowMap_cascadeMatrices[0] * weights.x +
  757. shadowMap_cascadeMatrices[1] * weights.y +
  758. shadowMap_cascadeMatrices[2] * weights.z +
  759. shadowMap_cascadeMatrices[3] * weights.w;
  760. }
  761. `;var zt=`
  762. uniform vec4 shadowMap_cascadeSplits[2];
  763. vec4 czm_cascadeWeights(float depthEye)
  764. {
  765. // One component is set to 1.0 and all others set to 0.0.
  766. vec4 near = step(shadowMap_cascadeSplits[0], vec4(depthEye));
  767. vec4 far = step(depthEye, shadowMap_cascadeSplits[1]);
  768. return near * far;
  769. }
  770. `;var bt=`#ifdef GL_OES_standard_derivatives
  771. #extension GL_OES_standard_derivatives : enable
  772. #endif
  773. uniform float clip_mode;
  774. uniform vec4 clip_planes[6];
  775. uniform vec4 clip_line_color;
  776. const float clip_lineWidth = 3.0;
  777. float GetClipDistance(vec3 pos, vec3 planeNormal, float disToOrigin)
  778. {
  779. return dot(planeNormal, pos) + disToOrigin;
  780. }
  781. float ClipBehindAllPlane(float fBorderWidth, vec4 clip_vertex)
  782. {
  783. float distance = 0.0;
  784. float result = -1.0;
  785. #ifdef CLIPPLANE
  786. distance = GetClipDistance(clip_vertex.xyz, clip_planes[0].xyz, clip_planes[0].w);
  787. if (distance < 0.0)
  788. {
  789. return 1.0;
  790. }
  791. else if (distance < fBorderWidth)
  792. {
  793. result = 0.0;
  794. }
  795. #else
  796. for(int i = 0; i < 6; i++)
  797. {
  798. distance = GetClipDistance(clip_vertex.xyz, clip_planes[i].xyz, clip_planes[i].w);
  799. if(distance < 0.0)
  800. {
  801. return 1.0;
  802. }
  803. else if(distance < fBorderWidth)
  804. {
  805. result = 0.0;
  806. }
  807. }
  808. #endif
  809. return result;
  810. }
  811. float ClipBehindAnyPlane(float fBorderWidth, vec4 clip_vertex)
  812. {
  813. float result = 1.0;
  814. for(int i = 0; i < 6; i++)
  815. {
  816. float distance = GetClipDistance(clip_vertex.xyz, clip_planes[i].xyz, clip_planes[i].w);
  817. if((distance + fBorderWidth) < 0.0)
  818. {
  819. return -1.0;
  820. }
  821. else if(distance < 0.0)
  822. {
  823. result = 0.0;
  824. }
  825. }
  826. return result;
  827. }
  828. float ClipAnythingButLine(float fBorderWidth, vec4 clip_vertex)
  829. {
  830. float result = -1.0;
  831. for(int i = 0; i < 6; i++)
  832. {
  833. float distance = GetClipDistance(clip_vertex.xyz, clip_planes[i].xyz, clip_planes[i].w);
  834. if(distance < 0.0)
  835. {
  836. return -1.0;
  837. }
  838. else if(distance < fBorderWidth)
  839. {
  840. result = 0.0;
  841. }
  842. }
  843. return result;
  844. }
  845. vec4 czm_clip(vec4 clip_vertex, float fIsFiltByID)
  846. {
  847. if(fIsFiltByID < 0.1)
  848. {
  849. return vec4(1.0);
  850. }
  851. if(clip_mode < 0.5)
  852. {
  853. return vec4(1.0);
  854. }
  855. #ifdef GL_OES_standard_derivatives
  856. float dxc = abs(dFdx(clip_vertex.x));
  857. float dyc = abs(dFdy(clip_vertex.y));
  858. float fBorderWidth = max(dxc, dyc) * clip_lineWidth;
  859. #else
  860. float fBorderWidth = clip_lineWidth;
  861. #endif
  862. float clipResult = 1.0;
  863. if(clip_line_color.a < 0.01)
  864. {
  865. fBorderWidth = 0.0;
  866. }
  867. if(clip_mode < 1.5)
  868. {
  869. clipResult = ClipBehindAnyPlane(fBorderWidth, clip_vertex);
  870. }
  871. else if(clip_mode < 2.5)
  872. {
  873. clipResult = ClipBehindAllPlane(fBorderWidth, clip_vertex);
  874. }
  875. else if(clip_mode < 3.5)
  876. {
  877. clipResult = ClipAnythingButLine(fBorderWidth, clip_vertex);
  878. }
  879. if(clipResult < -0.5)
  880. {
  881. discard;
  882. }
  883. else if(clipResult < 0.5)
  884. {
  885. return clip_line_color;
  886. }
  887. else
  888. {
  889. return vec4(1.0);
  890. }
  891. }`;var wt=`/**
  892. * DOC_TBA
  893. *
  894. * @name czm_columbusViewMorph
  895. * @glslFunction
  896. */
  897. vec4 czm_columbusViewMorph(vec4 position2D, vec4 position3D, float time)
  898. {
  899. // Just linear for now.
  900. vec3 p = mix(position2D.xyz, position3D.xyz, time);
  901. return vec4(p, 1.0);
  902. }
  903. `;var Lt=`vec4 czm_computeLightColorInFP(czm_s3mMaterialInput material, vec3 positionMC, float hasNormal, vec3 normal)
  904. {
  905. vec3 normalEC;
  906. #ifdef HAS_NORMAL
  907. float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  908. normalEC = normalize(normal) * faceDirection;
  909. #else
  910. normalEC = normalize(czm_normal*czm_computeNormal(positionMC));
  911. #endif
  912. vec3 positionEC = vec3(czm_modelView * vec4(positionMC,1.0)).xyz;
  913. return czm_directionLight(material, normalEC, -positionEC, positionMC);
  914. }`;var St=`vec4 czm_computeLightColorInstanceInFP(czm_s3mMaterialInput material, vec3 positionRotateMC, vec3 positionMC, float hasNormal, vec3 normal)
  915. {
  916. vec3 normalEC;
  917. #ifdef HAS_NORMAL
  918. float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  919. normalEC = normalize(normal) * faceDirection;
  920. #else
  921. normalEC = normalize(czm_normal*czm_computeNormal(positionRotateMC));
  922. #endif
  923. vec3 positionEC = vec3(czm_modelView * vec4(positionMC,1.0)).xyz;
  924. return czm_directionLight(material, normalEC, -positionEC, positionMC);
  925. }`;var Et=`float calculateLinearDepth(float z) {
  926. return (-z - czm_currentFrustum.x) / (czm_currentFrustum.y - czm_currentFrustum.x);
  927. }
  928. float _calculateFragDepth(const in float depth) {
  929. //const float SLOPE_SCALE = 2.0;
  930. //const float BIAS = 20.0 * .000015259;
  931. // TODO: webgpu\u662F\u5426\u505A\u5B8F\u63A7\u5236?
  932. float m = max(abs(dFdx(depth)), abs(dFdy(depth)));
  933. return depth + czm_linearDepthOffset.x * m + czm_linearDepthOffset.y;
  934. }
  935. // \u5199\u5165\u7EBF\u6027\u6DF1\u5EA6\uFF0C\u53EF\u4EE5\u7406\u89E3\u4E3A\u7269\u4F53\u76F8\u673A\u5750\u6807\u5230\u8FD1\u88C1\u526A\u9762\u7684\u8DDD\u79BB\uFF0C\u5728\u8FDC\u8FD1\u88C1\u526A\u9762\u8303\u56F4\u5185\u5F52\u4E00\u5316\u52300\u52301
  936. float czm_computeLinearDepth(vec4 positionEC)
  937. {
  938. #ifdef WEBGPU
  939. return calculateLinearDepth(positionEC.z);
  940. #else
  941. return _calculateFragDepth(calculateLinearDepth(positionEC.z));
  942. #endif
  943. }
  944. `;var At=`#ifdef GL_OES_standard_derivatives
  945. #extension GL_OES_standard_derivatives : enable
  946. #endif
  947. vec3 czm_computeNormal(in vec3 oriVertex)
  948. {
  949. vec3 normal = cross(vec3(dFdx(oriVertex.x), dFdx(oriVertex.y), dFdx(oriVertex.z)), vec3(dFdy(oriVertex.x), dFdy(oriVertex.y), dFdy(oriVertex.z)));
  950. normal = normalize(normal);
  951. return normal;
  952. }`;var Dt=`/**
  953. * Returns a position in model coordinates relative to eye taking into
  954. * account the current scene mode: 3D, 2D, or Columbus view.
  955. * <p>
  956. * This uses standard position attributes, <code>position3DHigh</code>,
  957. * <code>position3DLow</code>, <code>position2DHigh</code>, and <code>position2DLow</code>,
  958. * and should be used when writing a vertex shader for an {@link Appearance}.
  959. * </p>
  960. *
  961. * @name czm_computePosition
  962. * @glslFunction
  963. *
  964. * @returns {vec4} The position relative to eye.
  965. *
  966. * @example
  967. * vec4 p = czm_computePosition();
  968. * v_positionEC = (czm_modelViewRelativeToEye * p).xyz;
  969. * gl_Position = czm_modelViewProjectionRelativeToEye * p;
  970. *
  971. * @see czm_translateRelativeToEye
  972. */
  973. vec4 czm_computePosition();
  974. `;var Ot=`/**
  975. * @private
  976. */
  977. vec2 cordic(float angle)
  978. {
  979. // Scale the vector by the appropriate factor for the 24 iterations to follow.
  980. vec2 vector = vec2(6.0725293500888267e-1, 0.0);
  981. // Iteration 1
  982. float sense = (angle < 0.0) ? -1.0 : 1.0;
  983. // float factor = sense * 1.0; // 2^-0
  984. mat2 rotation = mat2(1.0, sense, -sense, 1.0);
  985. vector = rotation * vector;
  986. angle -= sense * 7.8539816339744828e-1; // atan(2^-0)
  987. // Iteration 2
  988. sense = (angle < 0.0) ? -1.0 : 1.0;
  989. float factor = sense * 5.0e-1; // 2^-1
  990. rotation[0][1] = factor;
  991. rotation[1][0] = -factor;
  992. vector = rotation * vector;
  993. angle -= sense * 4.6364760900080609e-1; // atan(2^-1)
  994. // Iteration 3
  995. sense = (angle < 0.0) ? -1.0 : 1.0;
  996. factor = sense * 2.5e-1; // 2^-2
  997. rotation[0][1] = factor;
  998. rotation[1][0] = -factor;
  999. vector = rotation * vector;
  1000. angle -= sense * 2.4497866312686414e-1; // atan(2^-2)
  1001. // Iteration 4
  1002. sense = (angle < 0.0) ? -1.0 : 1.0;
  1003. factor = sense * 1.25e-1; // 2^-3
  1004. rotation[0][1] = factor;
  1005. rotation[1][0] = -factor;
  1006. vector = rotation * vector;
  1007. angle -= sense * 1.2435499454676144e-1; // atan(2^-3)
  1008. // Iteration 5
  1009. sense = (angle < 0.0) ? -1.0 : 1.0;
  1010. factor = sense * 6.25e-2; // 2^-4
  1011. rotation[0][1] = factor;
  1012. rotation[1][0] = -factor;
  1013. vector = rotation * vector;
  1014. angle -= sense * 6.2418809995957350e-2; // atan(2^-4)
  1015. // Iteration 6
  1016. sense = (angle < 0.0) ? -1.0 : 1.0;
  1017. factor = sense * 3.125e-2; // 2^-5
  1018. rotation[0][1] = factor;
  1019. rotation[1][0] = -factor;
  1020. vector = rotation * vector;
  1021. angle -= sense * 3.1239833430268277e-2; // atan(2^-5)
  1022. // Iteration 7
  1023. sense = (angle < 0.0) ? -1.0 : 1.0;
  1024. factor = sense * 1.5625e-2; // 2^-6
  1025. rotation[0][1] = factor;
  1026. rotation[1][0] = -factor;
  1027. vector = rotation * vector;
  1028. angle -= sense * 1.5623728620476831e-2; // atan(2^-6)
  1029. // Iteration 8
  1030. sense = (angle < 0.0) ? -1.0 : 1.0;
  1031. factor = sense * 7.8125e-3; // 2^-7
  1032. rotation[0][1] = factor;
  1033. rotation[1][0] = -factor;
  1034. vector = rotation * vector;
  1035. angle -= sense * 7.8123410601011111e-3; // atan(2^-7)
  1036. // Iteration 9
  1037. sense = (angle < 0.0) ? -1.0 : 1.0;
  1038. factor = sense * 3.90625e-3; // 2^-8
  1039. rotation[0][1] = factor;
  1040. rotation[1][0] = -factor;
  1041. vector = rotation * vector;
  1042. angle -= sense * 3.9062301319669718e-3; // atan(2^-8)
  1043. // Iteration 10
  1044. sense = (angle < 0.0) ? -1.0 : 1.0;
  1045. factor = sense * 1.953125e-3; // 2^-9
  1046. rotation[0][1] = factor;
  1047. rotation[1][0] = -factor;
  1048. vector = rotation * vector;
  1049. angle -= sense * 1.9531225164788188e-3; // atan(2^-9)
  1050. // Iteration 11
  1051. sense = (angle < 0.0) ? -1.0 : 1.0;
  1052. factor = sense * 9.765625e-4; // 2^-10
  1053. rotation[0][1] = factor;
  1054. rotation[1][0] = -factor;
  1055. vector = rotation * vector;
  1056. angle -= sense * 9.7656218955931946e-4; // atan(2^-10)
  1057. // Iteration 12
  1058. sense = (angle < 0.0) ? -1.0 : 1.0;
  1059. factor = sense * 4.8828125e-4; // 2^-11
  1060. rotation[0][1] = factor;
  1061. rotation[1][0] = -factor;
  1062. vector = rotation * vector;
  1063. angle -= sense * 4.8828121119489829e-4; // atan(2^-11)
  1064. // Iteration 13
  1065. sense = (angle < 0.0) ? -1.0 : 1.0;
  1066. factor = sense * 2.44140625e-4; // 2^-12
  1067. rotation[0][1] = factor;
  1068. rotation[1][0] = -factor;
  1069. vector = rotation * vector;
  1070. angle -= sense * 2.4414062014936177e-4; // atan(2^-12)
  1071. // Iteration 14
  1072. sense = (angle < 0.0) ? -1.0 : 1.0;
  1073. factor = sense * 1.220703125e-4; // 2^-13
  1074. rotation[0][1] = factor;
  1075. rotation[1][0] = -factor;
  1076. vector = rotation * vector;
  1077. angle -= sense * 1.2207031189367021e-4; // atan(2^-13)
  1078. // Iteration 15
  1079. sense = (angle < 0.0) ? -1.0 : 1.0;
  1080. factor = sense * 6.103515625e-5; // 2^-14
  1081. rotation[0][1] = factor;
  1082. rotation[1][0] = -factor;
  1083. vector = rotation * vector;
  1084. angle -= sense * 6.1035156174208773e-5; // atan(2^-14)
  1085. // Iteration 16
  1086. sense = (angle < 0.0) ? -1.0 : 1.0;
  1087. factor = sense * 3.0517578125e-5; // 2^-15
  1088. rotation[0][1] = factor;
  1089. rotation[1][0] = -factor;
  1090. vector = rotation * vector;
  1091. angle -= sense * 3.0517578115526096e-5; // atan(2^-15)
  1092. // Iteration 17
  1093. sense = (angle < 0.0) ? -1.0 : 1.0;
  1094. factor = sense * 1.52587890625e-5; // 2^-16
  1095. rotation[0][1] = factor;
  1096. rotation[1][0] = -factor;
  1097. vector = rotation * vector;
  1098. angle -= sense * 1.5258789061315762e-5; // atan(2^-16)
  1099. // Iteration 18
  1100. sense = (angle < 0.0) ? -1.0 : 1.0;
  1101. factor = sense * 7.62939453125e-6; // 2^-17
  1102. rotation[0][1] = factor;
  1103. rotation[1][0] = -factor;
  1104. vector = rotation * vector;
  1105. angle -= sense * 7.6293945311019700e-6; // atan(2^-17)
  1106. // Iteration 19
  1107. sense = (angle < 0.0) ? -1.0 : 1.0;
  1108. factor = sense * 3.814697265625e-6; // 2^-18
  1109. rotation[0][1] = factor;
  1110. rotation[1][0] = -factor;
  1111. vector = rotation * vector;
  1112. angle -= sense * 3.8146972656064961e-6; // atan(2^-18)
  1113. // Iteration 20
  1114. sense = (angle < 0.0) ? -1.0 : 1.0;
  1115. factor = sense * 1.9073486328125e-6; // 2^-19
  1116. rotation[0][1] = factor;
  1117. rotation[1][0] = -factor;
  1118. vector = rotation * vector;
  1119. angle -= sense * 1.9073486328101870e-6; // atan(2^-19)
  1120. // Iteration 21
  1121. sense = (angle < 0.0) ? -1.0 : 1.0;
  1122. factor = sense * 9.5367431640625e-7; // 2^-20
  1123. rotation[0][1] = factor;
  1124. rotation[1][0] = -factor;
  1125. vector = rotation * vector;
  1126. angle -= sense * 9.5367431640596084e-7; // atan(2^-20)
  1127. // Iteration 22
  1128. sense = (angle < 0.0) ? -1.0 : 1.0;
  1129. factor = sense * 4.76837158203125e-7; // 2^-21
  1130. rotation[0][1] = factor;
  1131. rotation[1][0] = -factor;
  1132. vector = rotation * vector;
  1133. angle -= sense * 4.7683715820308884e-7; // atan(2^-21)
  1134. // Iteration 23
  1135. sense = (angle < 0.0) ? -1.0 : 1.0;
  1136. factor = sense * 2.384185791015625e-7; // 2^-22
  1137. rotation[0][1] = factor;
  1138. rotation[1][0] = -factor;
  1139. vector = rotation * vector;
  1140. angle -= sense * 2.3841857910155797e-7; // atan(2^-22)
  1141. // Iteration 24
  1142. sense = (angle < 0.0) ? -1.0 : 1.0;
  1143. factor = sense * 1.1920928955078125e-7; // 2^-23
  1144. rotation[0][1] = factor;
  1145. rotation[1][0] = -factor;
  1146. vector = rotation * vector;
  1147. // angle -= sense * 1.1920928955078068e-7; // atan(2^-23)
  1148. return vector;
  1149. }
  1150. /**
  1151. * Computes the cosine and sine of the provided angle using the CORDIC algorithm.
  1152. *
  1153. * @name czm_cosineAndSine
  1154. * @glslFunction
  1155. *
  1156. * @param {float} angle The angle in radians.
  1157. *
  1158. * @returns {vec2} The resulting cosine of the angle (as the x coordinate) and sine of the angle (as the y coordinate).
  1159. *
  1160. * @example
  1161. * vec2 v = czm_cosineAndSine(czm_piOverSix);
  1162. * float cosine = v.x;
  1163. * float sine = v.y;
  1164. */
  1165. vec2 czm_cosineAndSine(float angle)
  1166. {
  1167. if (angle < -czm_piOverTwo || angle > czm_piOverTwo)
  1168. {
  1169. if (angle < 0.0)
  1170. {
  1171. return -cordic(angle + czm_pi);
  1172. }
  1173. else
  1174. {
  1175. return -cordic(angle - czm_pi);
  1176. }
  1177. }
  1178. else
  1179. {
  1180. return cordic(angle);
  1181. }
  1182. }
  1183. `;var It=`/**
  1184. * Decompresses texture coordinates that were packed into a single float.
  1185. *
  1186. * @name czm_decompressTextureCoordinates
  1187. * @glslFunction
  1188. *
  1189. * @param {float} encoded The compressed texture coordinates.
  1190. * @returns {vec2} The decompressed texture coordinates.
  1191. */
  1192. vec2 czm_decompressTextureCoordinates(float encoded)
  1193. {
  1194. float temp = encoded / 4096.0;
  1195. float xZeroTo4095 = floor(temp);
  1196. float stx = xZeroTo4095 / 4095.0;
  1197. float sty = (encoded - xZeroTo4095 * 4096.0) / 4095.0;
  1198. return vec2(stx, sty);
  1199. }
  1200. `;var Rt=`// emulated noperspective
  1201. #if defined(GL_EXT_frag_depth) && !defined(LOG_DEPTH)
  1202. varying float v_WindowZ;
  1203. #endif
  1204. /**
  1205. * Emulates GL_DEPTH_CLAMP, which is not available in WebGL 1 or 2.
  1206. * GL_DEPTH_CLAMP clamps geometry that is outside the near and far planes,
  1207. * capping the shadow volume. More information here:
  1208. * https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_depth_clamp.txt.
  1209. *
  1210. * When GL_EXT_frag_depth is available we emulate GL_DEPTH_CLAMP by ensuring
  1211. * no geometry gets clipped by setting the clip space z value to 0.0 and then
  1212. * sending the unaltered screen space z value (using emulated noperspective
  1213. * interpolation) to the frag shader where it is clamped to [0,1] and then
  1214. * written with gl_FragDepth (see czm_writeDepthClamp). This technique is based on:
  1215. * https://stackoverflow.com/questions/5960757/how-to-emulate-gl-depth-clamp-nv.
  1216. *
  1217. * When GL_EXT_frag_depth is not available, which is the case on some mobile
  1218. * devices, we must attempt to fix this only in the vertex shader.
  1219. * The approach is to clamp the z value to the far plane, which closes the
  1220. * shadow volume but also distorts the geometry, so there can still be artifacts
  1221. * on frustum seams.
  1222. *
  1223. * @name czm_depthClamp
  1224. * @glslFunction
  1225. *
  1226. * @param {vec4} coords The vertex in clip coordinates.
  1227. * @returns {vec4} The modified vertex.
  1228. *
  1229. * @example
  1230. * gl_Position = czm_depthClamp(czm_modelViewProjection * vec4(position, 1.0));
  1231. *
  1232. * @see czm_writeDepthClamp
  1233. */
  1234. vec4 czm_depthClamp(vec4 coords)
  1235. {
  1236. #ifndef LOG_DEPTH
  1237. #ifdef GL_EXT_frag_depth
  1238. v_WindowZ = (0.5 * (coords.z / coords.w) + 0.5) * coords.w;
  1239. coords.z = 0.0;
  1240. #else
  1241. coords.z = min(coords.z, coords.w);
  1242. #endif
  1243. #endif
  1244. return coords;
  1245. }
  1246. `;var Mt=`// emulated noperspective
  1247. #ifndef LOG_DEPTH
  1248. varying float v_WindowZ;
  1249. #endif
  1250. /**
  1251. * Clamps a vertex to the far plane.
  1252. *
  1253. * @name czm_depthClampFarPlane
  1254. * @glslFunction
  1255. *
  1256. * @param {vec4} coords The vertex in clip coordinates.
  1257. * @returns {vec4} The vertex clipped to the far plane.
  1258. *
  1259. * @example
  1260. * gl_Position = czm_depthClampFarPlane(czm_modelViewProjection * vec4(position, 1.0));
  1261. *
  1262. * @see czm_writeDepthClampedToFarPlane
  1263. */
  1264. vec4 czm_depthClampFarPlane(vec4 coords)
  1265. {
  1266. #ifndef LOG_DEPTH
  1267. v_WindowZ = (0.5 * (coords.z / coords.w) + 0.5) * coords.w;
  1268. coords.z = min(coords.z, coords.w);
  1269. #endif
  1270. return coords;
  1271. }
  1272. `;var Pt=`const vec3 SideLightColor = vec3(0.0);
  1273. uniform vec4 uSpecularColor;
  1274. uniform float uShininess;
  1275. const vec3 specular = vec3(0.066666);
  1276. const float shininess2 = 30.0;
  1277. float saturate( in float a ) { return clamp( a, 0.0, 1.0 ); }
  1278. float calcLightAttenuation( float lightDistance, float cutoffDistance, float decayExponent ) {
  1279. if ( decayExponent > 0.0 ) {
  1280. return pow( saturate( 1.0 - lightDistance / cutoffDistance ), decayExponent );
  1281. }
  1282. return 1.0;
  1283. }
  1284. #if POINT_LIGHTS > 0
  1285. uniform vec3 uPointLightPositionEC[POINT_LIGHTS];
  1286. uniform vec3 uPointLightColor[POINT_LIGHTS];
  1287. uniform vec2 uPointLightDistanceAndDecay[POINT_LIGHTS];
  1288. #endif
  1289. #if SPOT_LIGHTS > 0
  1290. uniform vec3 uSpotLightPosition[ SPOT_LIGHTS ];
  1291. uniform vec3 uSpotLightColor[ SPOT_LIGHTS ];
  1292. uniform vec3 uSpotLightPositionEC[ SPOT_LIGHTS ];
  1293. uniform vec3 uSpotLightDirection[ SPOT_LIGHTS ];
  1294. uniform float uSpotLightExponent[ SPOT_LIGHTS ];
  1295. uniform vec4 uSpotLightDistanceDecayCosPenumbra[ SPOT_LIGHTS ];
  1296. #endif
  1297. #if DIR_LIGHTS > 0
  1298. uniform vec3 uDirectionalLightDirection[ DIR_LIGHTS ];
  1299. uniform vec3 uDirectionalLightColor[ DIR_LIGHTS];
  1300. #endif
  1301. #if HEMISPHERE_LIGHTS > 0
  1302. uniform vec3 uSkyColor[ HEMISPHERE_LIGHTS ];
  1303. uniform vec3 uGroundColor[ HEMISPHERE_LIGHTS];
  1304. #endif
  1305. vec3 calcAmbientIrradiance(vec3 normal) {
  1306. vec3 SH0 = czm_SH[0].xyz;
  1307. vec4 SH_R1 = czm_SH[1];
  1308. vec4 SH_G1 = czm_SH[2];
  1309. vec4 SH_B1 = czm_SH[3];
  1310. vec4 SH_R2 = czm_SH[4];
  1311. vec4 SH_G2 = czm_SH[5];
  1312. vec4 SH_B2 = czm_SH[6];
  1313. vec3 ambientLight = 0.282095 * SH0;
  1314. vec4 sh1 = vec4(
  1315. 0.488603 * normal.x,
  1316. 0.488603 * normal.z,
  1317. 0.488603 * normal.y,
  1318. 1.092548 * normal.x * normal.y
  1319. );
  1320. vec4 sh2 = vec4(
  1321. 1.092548 * normal.y * normal.z,
  1322. 0.315392 * (3.0 * normal.z * normal.z - 1.0),
  1323. 1.092548 * normal.x * normal.z,
  1324. 0.546274 * (normal.x * normal.x - normal.y * normal.y)
  1325. );
  1326. ambientLight += vec3(
  1327. dot(SH_R1, sh1),
  1328. dot(SH_G1, sh1),
  1329. dot(SH_B1, sh1)
  1330. );
  1331. ambientLight += vec3(
  1332. dot(SH_R2, sh2),
  1333. dot(SH_G2, sh2),
  1334. dot(SH_B2, sh2)
  1335. );
  1336. return ambientLight;
  1337. }
  1338. const float ambientBoostFactor = 0.4;
  1339. const float lightingGlobalFactor = 0.0000342739;
  1340. const float fillLightIntensity = 0.25;
  1341. const vec3 GROUND_REFLECTANCE = vec3(0.2);
  1342. vec3 evaluateAdditionalLighting(vec3 posWorld, vec3 mainLightDirection, vec3 mainLightIntensity) {
  1343. float vndl = dot(normalize(posWorld), mainLightDirection);
  1344. float additionalAmbientScale = smoothstep(0.0, 1.0, clamp(vndl * 2.0, 0.0, 1.0));
  1345. return additionalAmbientScale * ambientBoostFactor * lightingGlobalFactor * mainLightIntensity;
  1346. }
  1347. vec3 evaluateDiffuseIlluminationHemisphere(vec3 ambientGround, vec3 ambientSky, float NdotNG) {
  1348. return ((1.0 - NdotNG) * ambientGround + (1.0 + NdotNG) * ambientSky) * 0.5;
  1349. }
  1350. vec3 calcFinalIrradiance(float NdotL, vec3 normalWorld, vec3 normalGround, vec3 positionWC, vec3 lightDirWC, vec3 mainLightIntensity, vec3 ambientLightIrradiance, vec3 surfaceAlbedo, float shadow) {
  1351. float NdotNG = clamp(dot(normalWorld, normalGround), -1.0, 1.0);
  1352. vec3 ng = normalGround;
  1353. vec3 ambientDir = vec3(5.0 * ng[1] - ng[0] * ng[2], -5.0 * ng[0] - ng[2] * ng[1], ng[1] * ng[1] + ng[0] * ng[0]);
  1354. ambientDir = ambientDir != vec3(0.0) ? normalize(ambientDir) : normalize(vec3(5.0, -1.0, 0.0));
  1355. float NdotAmbDir = abs(dot(normalWorld, ambientDir));
  1356. vec3 additionalLight = evaluateAdditionalLighting(positionWC, lightDirWC, mainLightIntensity);
  1357. vec3 mainLightIrradiance = NdotL * mainLightIntensity * shadow;
  1358. vec3 fillLightIrradiance = NdotAmbDir * mainLightIntensity * fillLightIntensity;
  1359. vec3 ambientLightIrradianceComponent = ambientLightIrradiance + additionalLight;
  1360. vec3 skyIrradianceToSurface = ambientLightIrradianceComponent + mainLightIrradiance + fillLightIrradiance;
  1361. vec3 groundIrradianceToSurface = GROUND_REFLECTANCE * ambientLightIrradianceComponent + mainLightIrradiance + fillLightIrradiance;
  1362. vec3 diffuseContribution = evaluateDiffuseIlluminationHemisphere(groundIrradianceToSurface, skyIrradianceToSurface, NdotNG);
  1363. vec3 finalIrradiance = surfaceAlbedo.rgb * diffuseContribution * 0.31830988618;
  1364. return finalIrradiance;
  1365. }
  1366. vec3 diffuseBRDF_Lambertian(vec3 diffuseColor) {
  1367. return diffuseColor * 0.31830988618;
  1368. }
  1369. vec4 czm_directionLight(czm_s3mMaterialInput material, vec3 normalEC, vec3 positionToEyeEC, vec3 positionMC)
  1370. {
  1371. vec3 totalDiffuseLight = vec3(0.0);
  1372. vec3 totalSpecularLight = vec3(0.0);
  1373. float dotNL = saturate(dot(normalEC, material.sunDirectionEC));
  1374. vec3 normalWorld = material.normalWorld;
  1375. vec3 normalGround = material.normalGround;
  1376. vec3 positionWorld = material.positionWorld;
  1377. vec3 lightDirWC = material.sunDirectionWC;
  1378. vec3 sunLightColor = material.sunLightColor.rgb;
  1379. vec4 surfaceAlbedo = material.surfaceAlbedo;
  1380. float shadow = 1.0;
  1381. vec3 ambientLightIrradiance = calcAmbientIrradiance(normalWorld);
  1382. vec3 finalIrradiance = calcFinalIrradiance(dotNL, normalWorld, normalGround, positionWorld, lightDirWC, sunLightColor, ambientLightIrradiance, surfaceAlbedo.rgb, shadow);
  1383. vec3 positionToEyeECDir = normalize(positionToEyeEC);
  1384. #if HEMISPHERE_LIGHTS > 0
  1385. for ( int i = 0; i < HEMISPHERE_LIGHTS; i ++ )
  1386. {
  1387. vec3 dirVectorEC = normalize(czm_normal * vec3(0.0, 0.0, 1.0));
  1388. float dotProduct = dot( normalEC, dirVectorEC );
  1389. vec3 skyColor = uSkyColor[i];
  1390. vec3 groundColor = uGroundColor[i];
  1391. float hemiDiffuseWeight = 0.5 * dotProduct + 0.5;
  1392. vec3 irradiance = mix( groundColor, skyColor, hemiDiffuseWeight );
  1393. irradiance *= 3.141592653589793;
  1394. totalDiffuseLight += irradiance;
  1395. }
  1396. #endif
  1397. #if DIR_LIGHTS > 0
  1398. for ( int i = 0; i < DIR_LIGHTS; i ++ )
  1399. {
  1400. vec3 dirVectorEC = normalize((czm_view * vec4(uDirectionalLightDirection[ i ], 0.0)).xyz);
  1401. float dotProduct = dot( normalEC, dirVectorEC );
  1402. float dirDiffuseWeight = max( dotProduct, 0.0 );
  1403. totalDiffuseLight += uDirectionalLightColor[ i ] * dirDiffuseWeight * diffuseBRDF_Lambertian(surfaceAlbedo.rgb);
  1404. }
  1405. #endif
  1406. #if POINT_LIGHTS > 0
  1407. for ( int i = 0; i < POINT_LIGHTS; i ++ )
  1408. {
  1409. vec3 lVector = uPointLightPositionEC[i] + positionToEyeEC;
  1410. float lengthToLight = length( lVector );
  1411. float cutoffDis = uPointLightDistanceAndDecay[i].x;
  1412. if(lengthToLight > cutoffDis)
  1413. {
  1414. continue;
  1415. }
  1416. float attenuation = calcLightAttenuation( lengthToLight, cutoffDis, uPointLightDistanceAndDecay[i].y);
  1417. lVector = normalize( lVector );
  1418. float dotProduct = dot( normalEC, lVector );
  1419. float pointLightDiffuse = max( dotProduct, 0.0 );
  1420. totalDiffuseLight += uPointLightColor[i] * pointLightDiffuse * attenuation * diffuseBRDF_Lambertian(surfaceAlbedo.rgb);
  1421. }
  1422. #endif
  1423. #if SPOT_LIGHTS > 0
  1424. vec3 positionWC = (czm_model * vec4(positionMC, 1.0)).xyz;
  1425. for ( int i = 0; i < SPOT_LIGHTS; i ++ )
  1426. {
  1427. vec3 lVector = uSpotLightPositionEC[i] + positionToEyeEC;
  1428. float attenuation = calcLightAttenuation( length( lVector ), uSpotLightDistanceDecayCosPenumbra[i].x, uSpotLightDistanceDecayCosPenumbra[i].y);
  1429. lVector = normalize( lVector );
  1430. float spotEffect = dot( uSpotLightDirection[ i ], normalize( uSpotLightPosition[ i ] - positionWC ) );
  1431. if ( spotEffect > uSpotLightDistanceDecayCosPenumbra[i].z ) {
  1432. spotEffect = max( pow( max( spotEffect, 0.0 ), uSpotLightExponent[ i ] ), 0.0 );
  1433. float dotProduct = dot( normalEC, lVector );
  1434. float spotDiffuseWeight = max( dotProduct, 0.0 );
  1435. totalDiffuseLight += uSpotLightColor[ i ] * spotDiffuseWeight * attenuation * spotEffect * diffuseBRDF_Lambertian(surfaceAlbedo.rgb);
  1436. vec3 spotHalfVector = normalize( lVector + positionToEyeECDir );
  1437. float spotDotNormalHalf = max( dot( normalEC, spotHalfVector ), 0.0 );
  1438. float spotSpecularWeight = max( pow( spotDotNormalHalf, shininess2 ), 0.0 );
  1439. float specularNormalization = ( shininess2 + 2.0 ) / 8.0;
  1440. vec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVector, spotHalfVector ), 0.0 ), 5.0 );
  1441. totalSpecularLight += schlick * uSpotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * attenuation * specularNormalization * spotEffect;
  1442. }
  1443. }
  1444. #endif
  1445. vec4 color = vec4(finalIrradiance + totalDiffuseLight + totalSpecularLight, surfaceAlbedo.a);
  1446. return color;
  1447. }
  1448. `;var Vt=`/**
  1449. * Computes a 3x3 rotation matrix that transforms vectors from an ellipsoid's east-north-up coordinate system
  1450. * to eye coordinates. In east-north-up coordinates, x points east, y points north, and z points along the
  1451. * surface normal. East-north-up can be used as an ellipsoid's tangent space for operations such as bump mapping.
  1452. * <br /><br />
  1453. * The ellipsoid is assumed to be centered at the model coordinate's origin.
  1454. *
  1455. * @name czm_eastNorthUpToEyeCoordinates
  1456. * @glslFunction
  1457. *
  1458. * @param {vec3} positionMC The position on the ellipsoid in model coordinates.
  1459. * @param {vec3} normalEC The normalized ellipsoid surface normal, at <code>positionMC</code>, in eye coordinates.
  1460. *
  1461. * @returns {mat3} A 3x3 rotation matrix that transforms vectors from the east-north-up coordinate system to eye coordinates.
  1462. *
  1463. * @example
  1464. * // Transform a vector defined in the east-north-up coordinate
  1465. * // system, (0, 0, 1) which is the surface normal, to eye
  1466. * // coordinates.
  1467. * mat3 m = czm_eastNorthUpToEyeCoordinates(positionMC, normalEC);
  1468. * vec3 normalEC = m * vec3(0.0, 0.0, 1.0);
  1469. */
  1470. mat3 czm_eastNorthUpToEyeCoordinates(vec3 positionMC, vec3 normalEC)
  1471. {
  1472. vec3 tangentMC = normalize(vec3(-positionMC.y, positionMC.x, 0.0)); // normalized surface tangent in model coordinates
  1473. vec3 tangentEC = normalize(czm_normal3D * tangentMC); // normalized surface tangent in eye coordiantes
  1474. vec3 bitangentEC = normalize(cross(normalEC, tangentEC)); // normalized surface bitangent in eye coordinates
  1475. return mat3(
  1476. tangentEC.x, tangentEC.y, tangentEC.z,
  1477. bitangentEC.x, bitangentEC.y, bitangentEC.z,
  1478. normalEC.x, normalEC.y, normalEC.z);
  1479. }
  1480. `;var Ft=`/**
  1481. * DOC_TBA
  1482. *
  1483. * @name czm_ellipsoidContainsPoint
  1484. * @glslFunction
  1485. *
  1486. */
  1487. bool czm_ellipsoidContainsPoint(vec3 ellipsoid_inverseRadii, vec3 point)
  1488. {
  1489. vec3 scaled = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(point, 1.0)).xyz;
  1490. return (dot(scaled, scaled) <= 1.0);
  1491. }
  1492. `;var Bt=`/**
  1493. * DOC_TBA
  1494. *
  1495. * @name czm_ellipsoidNew
  1496. * @glslFunction
  1497. *
  1498. */
  1499. czm_ellipsoid czm_ellipsoidNew(vec3 center, vec3 radii)
  1500. {
  1501. vec3 inverseRadii = vec3(1.0 / radii.x, 1.0 / radii.y, 1.0 / radii.z);
  1502. vec3 inverseRadiiSquared = inverseRadii * inverseRadii;
  1503. czm_ellipsoid temp = czm_ellipsoid(center, radii, inverseRadii, inverseRadiiSquared);
  1504. return temp;
  1505. }
  1506. `;var Nt=`/**
  1507. * DOC_TBA
  1508. *
  1509. * @name czm_ellipsoidWgs84TextureCoordinates
  1510. * @glslFunction
  1511. */
  1512. vec2 czm_ellipsoidWgs84TextureCoordinates(vec3 normal)
  1513. {
  1514. return vec2(atan(normal.y, normal.x) * czm_oneOverTwoPi + 0.5, asin(normal.z) * czm_oneOverPi + 0.5);
  1515. }
  1516. `;var Ht=`/**
  1517. * Compares <code>left</code> and <code>right</code> componentwise. Returns <code>true</code>
  1518. * if they are within <code>epsilon</code> and <code>false</code> otherwise. The inputs
  1519. * <code>left</code> and <code>right</code> can be <code>float</code>s, <code>vec2</code>s,
  1520. * <code>vec3</code>s, or <code>vec4</code>s.
  1521. *
  1522. * @name czm_equalsEpsilon
  1523. * @glslFunction
  1524. *
  1525. * @param {} left The first vector.
  1526. * @param {} right The second vector.
  1527. * @param {float} epsilon The epsilon to use for equality testing.
  1528. * @returns {bool} <code>true</code> if the components are within <code>epsilon</code> and <code>false</code> otherwise.
  1529. *
  1530. * @example
  1531. * // GLSL declarations
  1532. * bool czm_equalsEpsilon(float left, float right, float epsilon);
  1533. * bool czm_equalsEpsilon(vec2 left, vec2 right, float epsilon);
  1534. * bool czm_equalsEpsilon(vec3 left, vec3 right, float epsilon);
  1535. * bool czm_equalsEpsilon(vec4 left, vec4 right, float epsilon);
  1536. */
  1537. bool czm_equalsEpsilon(vec4 left, vec4 right, float epsilon) {
  1538. return all(lessThanEqual(abs(left - right), vec4(epsilon)));
  1539. }
  1540. bool czm_equalsEpsilon(vec3 left, vec3 right, float epsilon) {
  1541. return all(lessThanEqual(abs(left - right), vec3(epsilon)));
  1542. }
  1543. bool czm_equalsEpsilon(vec2 left, vec2 right, float epsilon) {
  1544. return all(lessThanEqual(abs(left - right), vec2(epsilon)));
  1545. }
  1546. bool czm_equalsEpsilon(float left, float right, float epsilon) {
  1547. return (abs(left - right) <= epsilon);
  1548. }
  1549. `;var Ut=`#ifdef EXCAVATION
  1550. uniform sampler2D uExcavationTexture;
  1551. uniform float uExcavationMode;
  1552. uniform vec4 uExcavationRect;
  1553. varying vec4 vExcavationVertexPos;
  1554. vec2 CalculateExcavationPolyTexCoord(vec4 vertexPos, vec4 rectPos, out float ptInRect)
  1555. {
  1556. vec2 vecRatio = vec2(rectPos.z - rectPos.x, rectPos.w - rectPos.y);
  1557. vec2 texCoord = vec2(vertexPos.x - rectPos.x, vertexPos.y - rectPos.y);
  1558. texCoord.x = texCoord.x / vecRatio.x;
  1559. texCoord.y = texCoord.y / vecRatio.y;
  1560. ptInRect = step(0.0, texCoord.x) * step(0.0, texCoord.y) * step(0.0, 1.0 - texCoord.x) * step(0.0, 1.0 - texCoord.y);
  1561. texCoord = clamp(texCoord, vec2(0.0), vec2(1.0));
  1562. return texCoord;
  1563. }
  1564. bool czm_executeExcavation()
  1565. {
  1566. float hasExcavation = 1.0;
  1567. vec2 vecExcavationTexCoord = CalculateExcavationPolyTexCoord(vExcavationVertexPos, uExcavationRect, hasExcavation);
  1568. bool excavationInside = (uExcavationMode < 0.5);
  1569. if(hasExcavation < 0.1)
  1570. {
  1571. return !excavationInside;
  1572. }
  1573. if(excavationInside)
  1574. {
  1575. return texture2D(uExcavationTexture, vecExcavationTexCoord.xy).r > 0.5;
  1576. }
  1577. else
  1578. {
  1579. return texture2D(uExcavationTexture, vecExcavationTexCoord.xy).r < 0.5;
  1580. }
  1581. }
  1582. #endif`;var Gt=`/**
  1583. * DOC_TBA
  1584. *
  1585. * @name czm_eyeOffset
  1586. * @glslFunction
  1587. *
  1588. * @param {vec4} positionEC DOC_TBA.
  1589. * @param {vec3} eyeOffset DOC_TBA.
  1590. *
  1591. * @returns {vec4} DOC_TBA.
  1592. */
  1593. vec4 czm_eyeOffset(vec4 positionEC, vec3 eyeOffset)
  1594. {
  1595. // This equation is approximate in x and y.
  1596. vec4 p = positionEC;
  1597. vec4 zEyeOffset = normalize(p) * eyeOffset.z;
  1598. p.xy += eyeOffset.xy + zEyeOffset.xy;
  1599. p.z += zEyeOffset.z;
  1600. return p;
  1601. }
  1602. `;var kt=`/**
  1603. * Transforms a position from eye to window coordinates. The transformation
  1604. * from eye to clip coordinates is done using {@link czm_projection}.
  1605. * The transform from normalized device coordinates to window coordinates is
  1606. * done using {@link czm_viewportTransformation}, which assumes a depth range
  1607. * of <code>near = 0</code> and <code>far = 1</code>.
  1608. * <br /><br />
  1609. * This transform is useful when there is a need to manipulate window coordinates
  1610. * in a vertex shader as done by {@link BillboardCollection}.
  1611. *
  1612. * @name czm_eyeToWindowCoordinates
  1613. * @glslFunction
  1614. *
  1615. * @param {vec4} position The position in eye coordinates to transform.
  1616. *
  1617. * @returns {vec4} The transformed position in window coordinates.
  1618. *
  1619. * @see czm_modelToWindowCoordinates
  1620. * @see czm_projection
  1621. * @see czm_viewportTransformation
  1622. * @see BillboardCollection
  1623. *
  1624. * @example
  1625. * vec4 positionWC = czm_eyeToWindowCoordinates(positionEC);
  1626. */
  1627. vec4 czm_eyeToWindowCoordinates(vec4 positionEC)
  1628. {
  1629. vec4 q = czm_projection * positionEC; // clip coordinates
  1630. q.xyz /= q.w; // normalized device coordinates
  1631. q.xyz = (czm_viewportTransformation * vec4(q.xyz, 1.0)).xyz; // window coordinates
  1632. return q;
  1633. }
  1634. `;var Wt=`/**
  1635. * Approxiamtes atan over the range [0, 1]. Safe to flip output for negative input.
  1636. *
  1637. * Based on Michal Drobot's approximation from ShaderFastLibs, which in turn is based on
  1638. * "Efficient approximations for the arctangent function," Rajan, S. Sichun Wang Inkol, R. Joyal, A., May 2006.
  1639. * Adapted from ShaderFastLibs under MIT License.
  1640. *
  1641. * Chosen for the following characteristics over range [0, 1]:
  1642. * - basically no error at 0 and 1, important for getting around range limit (naive atan2 via atan requires infinite range atan)
  1643. * - no visible artifacts from first-derivative discontinuities, unlike latitude via range-reduced sqrt asin approximations (at equator)
  1644. *
  1645. * The original code is x * (-0.1784 * abs(x) - 0.0663 * x * x + 1.0301);
  1646. * Removed the abs() in here because it isn't needed, the input range is guaranteed as [0, 1] by how we're approximating atan2.
  1647. *
  1648. * @name czm_fastApproximateAtan
  1649. * @glslFunction
  1650. *
  1651. * @param {float} x Value between 0 and 1 inclusive.
  1652. *
  1653. * @returns {float} Approximation of atan(x)
  1654. */
  1655. float czm_fastApproximateAtan(float x) {
  1656. return x * (-0.1784 * x - 0.0663 * x * x + 1.0301);
  1657. }
  1658. /**
  1659. * Approximation of atan2.
  1660. *
  1661. * Range reduction math based on nvidia's cg reference implementation for atan2:
  1662. * However, we replaced their atan curve with Michael Drobot's (see above).
  1663. *
  1664. * @name czm_fastApproximateAtan
  1665. * @glslFunction
  1666. *
  1667. * @param {float} x Value between -1 and 1 inclusive.
  1668. * @param {float} y Value between -1 and 1 inclusive.
  1669. *
  1670. * @returns {float} Approximation of atan2(x, y)
  1671. */
  1672. float czm_fastApproximateAtan(float x, float y) {
  1673. // atan approximations are usually only reliable over [-1, 1], or, in our case, [0, 1] due to modifications.
  1674. // So range-reduce using abs and by flipping whether x or y is on top.
  1675. float t = abs(x); // t used as swap and atan result.
  1676. float opposite = abs(y);
  1677. float adjacent = max(t, opposite);
  1678. opposite = min(t, opposite);
  1679. t = czm_fastApproximateAtan(opposite / adjacent);
  1680. // Undo range reduction
  1681. t = czm_branchFreeTernary(abs(y) > abs(x), czm_piOverTwo - t, t);
  1682. t = czm_branchFreeTernary(x < 0.0, czm_pi - t, t);
  1683. t = czm_branchFreeTernary(y < 0.0, -t, t);
  1684. return t;
  1685. }
  1686. `;var qt=`
  1687. const float MAX_RGBA4_FLOAT =
  1688. 15.0 / 16.0 +
  1689. 15.0 / 16.0 / 16.0 +
  1690. 15.0 / 16.0 / 16.0 / 16.0 +
  1691. 15.0 / 16.0 / 16.0 / 16.0 / 16.0;
  1692. const vec4 FIXED_POINT_FACTORS_RGBA4 = vec4(1.0, 16.0, 16.0 * 16.0, 16.0 * 16.0 * 16.0);
  1693. vec4 czm_floatToRGBA4(const float value) {
  1694. float valueInValidDomain = clamp(value, 0.0, MAX_RGBA4_FLOAT);
  1695. vec4 fixedPointU4 = floor(fract(valueInValidDomain * FIXED_POINT_FACTORS_RGBA4) * 16.0);
  1696. const float toU4AsFloat = 1.0 / 15.0;
  1697. return fixedPointU4 * toU4AsFloat;
  1698. }
  1699. `;var Xt=`/**
  1700. * Gets the color with fog at a distance from the camera.
  1701. *
  1702. * @name czm_fog
  1703. * @glslFunction
  1704. *
  1705. * @param {float} distanceToCamera The distance to the camera in meters.
  1706. * @param {vec3} color The original color.
  1707. * @param {vec3} fogColor The color of the fog.
  1708. *
  1709. * @returns {vec3} The color adjusted for fog at the distance from the camera.
  1710. */
  1711. vec3 czm_fog(float distanceToCamera, vec3 color, vec3 fogColor)
  1712. {
  1713. float scalar = distanceToCamera * czm_fogDensity;
  1714. float fog = 1.0 - exp(-(scalar * scalar));
  1715. return mix(color, fogColor, fog);
  1716. }
  1717. /**
  1718. * Gets the color with fog at a distance from the camera.
  1719. *
  1720. * @name czm_fog
  1721. * @glslFunction
  1722. *
  1723. * @param {float} distanceToCamera The distance to the camera in meters.
  1724. * @param {vec3} color The original color.
  1725. * @param {vec3} fogColor The color of the fog.
  1726. * @param {float} fogModifierConstant A constant to modify the appearance of fog.
  1727. *
  1728. * @returns {vec3} The color adjusted for fog at the distance from the camera.
  1729. */
  1730. vec3 czm_fog(float distanceToCamera, vec3 color, vec3 fogColor, float fogModifierConstant)
  1731. {
  1732. float scalar = distanceToCamera * czm_fogDensity;
  1733. float fog = 1.0 - exp(-((fogModifierConstant * scalar + fogModifierConstant) * (scalar * (1.0 + fogModifierConstant))));
  1734. return mix(color, fogColor, fog);
  1735. }
  1736. `;var Yt=`/**
  1737. * Converts a color from RGB space to linear space.
  1738. *
  1739. * @name czm_gammaCorrect
  1740. * @glslFunction
  1741. *
  1742. * @param {vec3} color The color in RGB space.
  1743. * @returns {vec3} The color in linear space.
  1744. */
  1745. vec3 czm_gammaCorrect(vec3 color) {
  1746. #ifdef HDR
  1747. color = pow(color, vec3(czm_gamma));
  1748. #endif
  1749. return color;
  1750. }
  1751. vec4 czm_gammaCorrect(vec4 color) {
  1752. #ifdef HDR
  1753. color.rgb = pow(color.rgb, vec3(czm_gamma));
  1754. #endif
  1755. return color;
  1756. }
  1757. `;var jt=`/**
  1758. * DOC_TBA
  1759. *
  1760. * @name czm_geodeticSurfaceNormal
  1761. * @glslFunction
  1762. *
  1763. * @param {vec3} positionOnEllipsoid DOC_TBA
  1764. * @param {vec3} ellipsoidCenter DOC_TBA
  1765. * @param {vec3} oneOverEllipsoidRadiiSquared DOC_TBA
  1766. *
  1767. * @returns {vec3} DOC_TBA.
  1768. */
  1769. vec3 czm_geodeticSurfaceNormal(vec3 positionOnEllipsoid, vec3 ellipsoidCenter, vec3 oneOverEllipsoidRadiiSquared)
  1770. {
  1771. return normalize((positionOnEllipsoid - ellipsoidCenter) * oneOverEllipsoidRadiiSquared);
  1772. }
  1773. `;var Zt=`/**
  1774. * An czm_material with default values. Every material's czm_getMaterial
  1775. * should use this default material as a base for the material it returns.
  1776. * The default normal value is given by materialInput.normalEC.
  1777. *
  1778. * @name czm_getDefaultMaterial
  1779. * @glslFunction
  1780. *
  1781. * @param {czm_materialInput} input The input used to construct the default material.
  1782. *
  1783. * @returns {czm_material} The default material.
  1784. *
  1785. * @see czm_materialInput
  1786. * @see czm_material
  1787. * @see czm_getMaterial
  1788. */
  1789. czm_material czm_getDefaultMaterial(czm_materialInput materialInput)
  1790. {
  1791. czm_material material;
  1792. material.diffuse = vec3(0.0);
  1793. material.specular = 0.0;
  1794. material.shininess = 1.0;
  1795. material.normal = materialInput.normalEC;
  1796. material.emission = vec3(0.0);
  1797. material.alpha = 1.0;
  1798. return material;
  1799. }
  1800. `;var Kt=`uniform float uMaxCategoryOrHypCeil;
  1801. uniform float uMinCategoryOrHypFloor;
  1802. uniform sampler2D uEmissionTexAtlas;
  1803. uniform vec4 uEmissionTexAtlasTilingAndOffset[EMISSION_TEXTURE_COUNT];
  1804. uniform vec4 uEmissionTexAtlasRects[EMISSION_TEXTURE_COUNT];
  1805. uniform float uLayerCornerLength;
  1806. varying vec2 vLayerTexCoord;
  1807. varying vec2 vModIndexAndTexIndex;
  1808. vec3 czm_getEmissiveTextureColor(float w)
  1809. {
  1810. vec3 texColor = vec3(0.0);
  1811. vec2 emissionTexCoord;
  1812. int nEmissionTexTexIdx = int(floor(vModIndexAndTexIndex.y + 0.5));
  1813. vec2 atlasTexCoord;
  1814. for(int i = 0; i < EMISSION_TEXTURE_COUNT; i++){
  1815. if(nEmissionTexTexIdx == i){
  1816. emissionTexCoord.x = mod(length(vLayerTexCoord) * uLayerCornerLength / uEmissionTexAtlasTilingAndOffset[i].x, 1.0);
  1817. emissionTexCoord.y = mod((w - uMinCategoryOrHypFloor) / uEmissionTexAtlasTilingAndOffset[i].y, 1.0) ;
  1818. emissionTexCoord.x += uEmissionTexAtlasTilingAndOffset[i].z;
  1819. emissionTexCoord.y += vModIndexAndTexIndex.x + uEmissionTexAtlasTilingAndOffset[i].w;
  1820. emissionTexCoord.xy = fract(emissionTexCoord.xy);
  1821. atlasTexCoord = mix(uEmissionTexAtlasRects[i].xy, uEmissionTexAtlasRects[i].zw, emissionTexCoord);
  1822. break;
  1823. }
  1824. }
  1825. texColor = texture2D(uEmissionTexAtlas, atlasTexCoord).rgb;
  1826. return texColor;
  1827. }
  1828. vec3 czm_getEmissiveTextureColor(float w, vec2 texCoord)
  1829. {
  1830. vec3 texColor = vec3(0.0);
  1831. vec2 emissionTexCoord;
  1832. int nEmissionTexTexIdx = int(floor(vModIndexAndTexIndex.y + 0.5));
  1833. vec2 atlasTexCoord;
  1834. for(int i = 0; i < EMISSION_TEXTURE_COUNT; i++){
  1835. if(nEmissionTexTexIdx == i){
  1836. emissionTexCoord.x = mod(texCoord.x / uEmissionTexAtlasTilingAndOffset[i].x, 1.0);
  1837. emissionTexCoord.y = mod(texCoord.y / uEmissionTexAtlasTilingAndOffset[i].y, 1.0);
  1838. emissionTexCoord.x += uEmissionTexAtlasTilingAndOffset[i].z;
  1839. emissionTexCoord.y += vModIndexAndTexIndex.x + uEmissionTexAtlasTilingAndOffset[i].w;
  1840. emissionTexCoord.xy = fract(emissionTexCoord.xy);
  1841. atlasTexCoord = mix(uEmissionTexAtlasRects[i].xy, uEmissionTexAtlasRects[i].zw, emissionTexCoord);
  1842. break;
  1843. }
  1844. }
  1845. texColor = texture2D(uEmissionTexAtlas, atlasTexCoord).rgb;
  1846. return texColor;
  1847. }`;var Qt=`uniform float uHorizontalLine;
  1848. uniform vec4 uHorizontalColor;
  1849. float computeContourline(float fValue)
  1850. {
  1851. float distanceToContour = uHorizontalLine;
  1852. float dxc = abs(dFdx(fValue));
  1853. float dyc = abs(dFdy(fValue));
  1854. float dF = max(dxc, dyc);
  1855. return (abs(distanceToContour-fValue) < dF) ? 1.0 : 0.0;
  1856. }
  1857. vec4 czm_getHorizontalColor(vec4 oriColor, float fValue)
  1858. {
  1859. float finalOpacity = computeContourline(fValue);
  1860. return mix(oriColor,uHorizontalColor, finalOpacity);
  1861. }`;var Jt=`uniform sampler2D uHypsometricTexture;
  1862. uniform sampler2D uHypsometricRenderTexture;
  1863. uniform float uHypsometricVisible;
  1864. uniform float uHypOpacity;
  1865. uniform float uHypContourInterval;
  1866. uniform vec4 uHypLineColor;
  1867. uniform float uHypContourFillMode;
  1868. uniform float uHypFloor;
  1869. uniform float uHypCeil;
  1870. uniform float uHypMaxVisibleValue;
  1871. uniform float uHypMinVisibleValue;
  1872. uniform float uHypHasAnalysisRegion;
  1873. varying vec2 vecHypTexCoord;
  1874. uniform float uMixColorType;
  1875. uniform vec4 uNoValueColor;
  1876. #ifdef Volume
  1877. varying vec3 vecRotioCoord;
  1878. uniform float uDataFloor;
  1879. uniform float uDataCeil;
  1880. uniform float uVolumeType;
  1881. #endif
  1882. #ifdef Volume2
  1883. uniform float uDataFloor;
  1884. uniform float uDataCeil;
  1885. uniform float uFilterMode;
  1886. #endif
  1887. float computeMixCon(float fValue)
  1888. {
  1889. float distanceToContour;
  1890. if(abs(uHypMaxVisibleValue - uHypMinVisibleValue) > 0.1)
  1891. {
  1892. if(fValue < 0.5)
  1893. {
  1894. distanceToContour = mod(fValue - 0.0002, uHypContourInterval);
  1895. }
  1896. else
  1897. {
  1898. float t = floor(fValue / uHypContourInterval);
  1899. distanceToContour = abs(fValue - (t * uHypContourInterval) - 0.1);
  1900. }
  1901. }
  1902. else
  1903. {
  1904. distanceToContour = abs(fValue - uHypMaxVisibleValue);
  1905. }
  1906. float dxc = abs(dFdx(fValue));
  1907. float dyc = abs(dFdy(fValue));
  1908. float dF = max(dxc, dyc);
  1909. return (distanceToContour < dF) ? 1.0 : 0.0;
  1910. }
  1911. vec4 computeContourMapColor(float fValue)
  1912. {
  1913. //float threshold = clamp(abs(uHypCeil - uHypFloor), 0.000001, 20000.0);
  1914. float threshold = abs(uHypCeil - uHypFloor);
  1915. float contourRate = (fValue - uHypFloor) / threshold;
  1916. float finalCoord = clamp(contourRate, 0.0, 1.0);
  1917. float count = floor(finalCoord * 16.0);
  1918. float y = (count*2.0 + 1.0)/32.0;
  1919. float x = fract(finalCoord*16.0);
  1920. if(y > 1.0)
  1921. {
  1922. x = 1.0;
  1923. }
  1924. vec2 contourCoord = vec2(x, y);
  1925. vec4 color = texture2D(uHypsometricTexture, contourCoord);
  1926. return color;
  1927. }
  1928. #ifdef Volume2
  1929. vec4 czm_getContourMapColor(vec4 oriColor, vec4 volColor)
  1930. {
  1931. if(uFilterMode > 0.5)
  1932. {
  1933. vec4 finalColor = volColor * oriColor;
  1934. if(uMixColorType > 0.5)
  1935. {
  1936. finalColor = volColor;
  1937. }
  1938. return finalColor;
  1939. }
  1940. vec4 contourMapColor = vec4(0.0);
  1941. float finalOpacity = uHypOpacity;
  1942. float noValue = volColor.a;
  1943. float texTest = clamp(czm_unpackVolume(volColor.zyx),0.0,1.0);
  1944. float fValue;
  1945. if(noValue > 0.5)
  1946. {
  1947. fValue = uDataFloor + texTest * (uDataCeil - uDataFloor);
  1948. }
  1949. else
  1950. {
  1951. fValue = uHypMaxVisibleValue + abs(uHypMaxVisibleValue * 0.1);
  1952. }
  1953. float extendHeight = czm_branchFreeTernary(uHypContourFillMode > 2.9, 0.0, czm_branchFreeTernary(uHypContourFillMode > 1.9, 5.0, 0.0));
  1954. if(fValue > uHypMaxVisibleValue + extendHeight || fValue < uHypMinVisibleValue - extendHeight)
  1955. {
  1956. return uNoValueColor * oriColor;
  1957. }
  1958. #ifdef GL_OES_standard_derivatives
  1959. if(uHypContourFillMode > 2.9)
  1960. {
  1961. float mix_con = computeMixCon(fValue);
  1962. contourMapColor = mix(computeContourMapColor(fValue), uHypLineColor, mix_con);
  1963. }
  1964. else if(uHypContourFillMode > 1.9)
  1965. {
  1966. finalOpacity = computeMixCon(fValue);
  1967. contourMapColor = uHypLineColor;
  1968. }
  1969. else if(uHypContourFillMode > 0.9)
  1970. #else
  1971. if(uHypContourFillMode > 0.9)
  1972. #endif
  1973. {
  1974. contourMapColor = computeContourMapColor(fValue);
  1975. }
  1976. else
  1977. {
  1978. finalOpacity = 0.0;
  1979. }
  1980. vec4 mixColor = mix(vec4(1.0,1.0,1.0,1.0), contourMapColor, finalOpacity);
  1981. vec4 finalColor = mixColor * oriColor;
  1982. #ifdef PT_CLOUD
  1983. finalColor = mixColor;
  1984. #endif
  1985. if(uMixColorType > 0.5)
  1986. {
  1987. finalColor = mixColor;
  1988. }
  1989. return finalColor;
  1990. }
  1991. #else
  1992. vec4 czm_getContourMapColor(vec4 oriColor, float fValue)
  1993. {
  1994. vec4 contourMapColor = vec4(0.0);
  1995. float finalOpacity = uHypOpacity;
  1996. #ifdef Volume
  1997. vec3 aRatioT = vecRotioCoord;
  1998. if((aRatioT.x < 1.0 && aRatioT.x >0.0) && (aRatioT.y < 1.0 && aRatioT.y >0.0) && (aRatioT.z < 1.0 && aRatioT.z >0.0))
  1999. {
  2000. if(uVolumeType > 0.5)
  2001. {
  2002. vec4 volumeColor = czm_getVolumeValue(aRatioT);
  2003. if(uMixColorType > 0.5)
  2004. {
  2005. volumeColor = volumeColor * oriColor;
  2006. }
  2007. return volumeColor;
  2008. }
  2009. float noValue;
  2010. float texTest = czm_getVolumeValue(aRatioT, noValue);
  2011. if(noValue > 0.5)
  2012. {
  2013. fValue = uDataFloor + texTest * (uDataCeil - uDataFloor);
  2014. }
  2015. else
  2016. {
  2017. fValue = uHypMaxVisibleValue + abs(uHypMaxVisibleValue * 0.1);
  2018. }
  2019. }
  2020. else
  2021. {
  2022. fValue = uHypMaxVisibleValue + abs(uHypMaxVisibleValue * 0.1);
  2023. }
  2024. #endif
  2025. float extendHeight = czm_branchFreeTernary(uHypContourFillMode > 2.9, 0.0, czm_branchFreeTernary(uHypContourFillMode > 1.9, 5.0, 0.0));
  2026. if(fValue > uHypMaxVisibleValue + extendHeight || fValue < uHypMinVisibleValue - extendHeight)
  2027. {
  2028. return uNoValueColor * oriColor;
  2029. }
  2030. #ifdef GL_OES_standard_derivatives
  2031. if(uHypContourFillMode > 2.9)
  2032. {
  2033. float mix_con = computeMixCon(fValue);
  2034. contourMapColor = mix(computeContourMapColor(fValue), uHypLineColor, mix_con);
  2035. }
  2036. else if(uHypContourFillMode > 1.9)
  2037. {
  2038. finalOpacity = computeMixCon(fValue);
  2039. contourMapColor = uHypLineColor;
  2040. }
  2041. else if(uHypContourFillMode > 0.9)
  2042. #else
  2043. if(uHypContourFillMode > 0.9)
  2044. #endif
  2045. {
  2046. contourMapColor = computeContourMapColor(fValue);
  2047. }
  2048. else
  2049. {
  2050. finalOpacity = 0.0;
  2051. }
  2052. vec4 mixColor = mix(vec4(1.0,1.0,1.0,1.0), contourMapColor, finalOpacity);
  2053. vec4 finalColor = mix(oriColor, contourMapColor, finalOpacity);
  2054. #ifdef PT_CLOUD
  2055. finalColor = mixColor;
  2056. #endif
  2057. #ifdef Volume
  2058. if(uMixColorType > 0.5)
  2059. {
  2060. finalColor = mixColor;
  2061. }
  2062. #endif
  2063. return finalColor;
  2064. }
  2065. #endif
  2066. #ifdef Volume2
  2067. vec4 czm_getHypsometricColor(vec4 oriColor, vec4 volColor)
  2068. {
  2069. if(uHypHasAnalysisRegion > 0.1)
  2070. {
  2071. vec4 hypColor = texture2D(uHypsometricRenderTexture, vecHypTexCoord);
  2072. if(hypColor.r < 0.1)
  2073. {
  2074. return oriColor;
  2075. }
  2076. }
  2077. return czm_getContourMapColor(oriColor, volColor);
  2078. }
  2079. #else
  2080. vec4 czm_getHypsometricColor(vec4 oriColor, float wValue)
  2081. {
  2082. float fValue = wValue;
  2083. if(uHypHasAnalysisRegion > 0.1)
  2084. {
  2085. vec4 hypColor = texture2D(uHypsometricRenderTexture, vecHypTexCoord);
  2086. if(hypColor.r < 0.1)
  2087. {
  2088. return oriColor;
  2089. }
  2090. }
  2091. return czm_getContourMapColor(oriColor, fValue);
  2092. }
  2093. vec4 czm_getHypsometricColorByGeoBounds(vec4 oriColor, float wValue, vec4 hypRect, vec2 vTexCoord, vec4 geoBounds)
  2094. {
  2095. if(uHypHasAnalysisRegion > 0.1)
  2096. {
  2097. vec2 polyTexCoord = vTexCoord.xy;
  2098. polyTexCoord.x = polyTexCoord.x * (geoBounds.z - geoBounds.x) + geoBounds.x;
  2099. polyTexCoord.y = polyTexCoord.y * (geoBounds.w - geoBounds.y) + geoBounds.y;
  2100. if(polyTexCoord.x < hypRect.x || polyTexCoord.x>hypRect.z || polyTexCoord.y< hypRect.y || polyTexCoord.y > hypRect.w)
  2101. {
  2102. return oriColor;
  2103. }
  2104. vec4 hypColor = texture2D(uHypsometricRenderTexture, polyTexCoord);
  2105. if(hypColor.r < 0.1)
  2106. {
  2107. return oriColor;
  2108. }
  2109. }
  2110. return czm_getContourMapColor(oriColor, wValue);
  2111. }
  2112. #endif`;var $t=`/**
  2113. * Calculates the intensity of diffusely reflected light.
  2114. *
  2115. * @name czm_getLambertDiffuse
  2116. * @glslFunction
  2117. *
  2118. * @param {vec3} lightDirectionEC Unit vector pointing to the light source in eye coordinates.
  2119. * @param {vec3} normalEC The surface normal in eye coordinates.
  2120. *
  2121. * @returns {float} The intensity of the diffuse reflection.
  2122. *
  2123. * @see czm_phong
  2124. *
  2125. * @example
  2126. * float diffuseIntensity = czm_getLambertDiffuse(lightDirectionEC, normalEC);
  2127. * float specularIntensity = czm_getSpecular(lightDirectionEC, toEyeEC, normalEC, 200);
  2128. * vec3 color = (diffuseColor * diffuseIntensity) + (specularColor * specularIntensity);
  2129. */
  2130. float czm_getLambertDiffuse(vec3 lightDirectionEC, vec3 normalEC)
  2131. {
  2132. return max(dot(lightDirectionEC, normalEC), 0.0);
  2133. }
  2134. `;var eo=`/**
  2135. * Calculates the specular intensity of reflected light.
  2136. *
  2137. * @name czm_getSpecular
  2138. * @glslFunction
  2139. *
  2140. * @param {vec3} lightDirectionEC Unit vector pointing to the light source in eye coordinates.
  2141. * @param {vec3} toEyeEC Unit vector pointing to the eye position in eye coordinates.
  2142. * @param {vec3} normalEC The surface normal in eye coordinates.
  2143. * @param {float} shininess The sharpness of the specular reflection. Higher values create a smaller, more focused specular highlight.
  2144. *
  2145. * @returns {float} The intensity of the specular highlight.
  2146. *
  2147. * @see czm_phong
  2148. *
  2149. * @example
  2150. * float diffuseIntensity = czm_getLambertDiffuse(lightDirectionEC, normalEC);
  2151. * float specularIntensity = czm_getSpecular(lightDirectionEC, toEyeEC, normalEC, 200);
  2152. * vec3 color = (diffuseColor * diffuseIntensity) + (specularColor * specularIntensity);
  2153. */
  2154. float czm_getSpecular(vec3 lightDirectionEC, vec3 toEyeEC, vec3 normalEC, float shininess)
  2155. {
  2156. vec3 toReflectedLight = reflect(-lightDirectionEC, normalEC);
  2157. float specular = max(dot(toReflectedLight, toEyeEC), 0.0);
  2158. // pow has undefined behavior if both parameters <= 0.
  2159. // Prevent this by making sure shininess is at least czm_epsilon2.
  2160. return pow(specular, max(shininess, czm_epsilon2));
  2161. }
  2162. `;var no=`void CalculateMipLevel(in vec2 inTexCoord, in float vecTile, in float fMaxMip, inout float mipLevel)
  2163. {
  2164. vec2 dx = dFdx(inTexCoord * vecTile);
  2165. vec2 dy = dFdy(inTexCoord * vecTile);
  2166. float dotX = dot(dx, dx);
  2167. float dotY = dot(dy, dy);
  2168. float dMax = max(dotX, dotY);
  2169. float dMin = min(dotX, dotY);
  2170. float offset = (dMax - dMin) / (dMax + dMin);
  2171. offset = clamp(offset, 0.0, 1.0);
  2172. float d = dMax * (1.0 - offset) + dMin * offset;
  2173. mipLevel = 0.5 * log2(d);
  2174. mipLevel = clamp(mipLevel, 0.0, fMaxMip - 1.62);
  2175. }
  2176. void CalculateMipLevel(in vec2 inTexCoord, in vec2 vecTile, in float fMaxMip, inout float mipLevel)
  2177. {
  2178. vec2 dx = dFdx(inTexCoord * vecTile.x);
  2179. vec2 dy = dFdy(inTexCoord * vecTile.y);
  2180. float dotX = dot(dx, dx);
  2181. float dotY = dot(dy, dy);
  2182. float dMax = max(dotX, dotY);
  2183. float dMin = min(dotX, dotY);
  2184. float offset = (dMax - dMin) / (dMax + dMin);
  2185. offset = clamp(offset, 0.0, 1.0);
  2186. float d = dMax * (1.0 - offset) + dMin * offset;
  2187. mipLevel = 0.5 * log2(d);
  2188. mipLevel = clamp(mipLevel, 0.0, fMaxMip - 1.62);
  2189. }
  2190. void CalculateTexCoord(in vec3 inTexCoord, in float scale, in float XTran, in float YTran, in float fTile, in float mipLevel, inout vec2 outTexCoord)
  2191. {
  2192. if(inTexCoord.z < -9000.0)
  2193. {
  2194. outTexCoord = inTexCoord.xy;
  2195. }
  2196. else
  2197. {
  2198. vec2 fTexCoord = fract(inTexCoord.xy);
  2199. float offset = 1.0 * pow(2.0, mipLevel) / fTile;
  2200. fTexCoord = clamp(fTexCoord, offset, 1.0 - offset);
  2201. outTexCoord.x = (fTexCoord.x + XTran) * scale;
  2202. outTexCoord.y = (fTexCoord.y + YTran) * scale;
  2203. }
  2204. }
  2205. #ifdef USE_UVRegion
  2206. varying vec4 uvAtlasRegion;
  2207. vec4 textureAtlasLookup(sampler2D tex, vec2 textureCoordinates) {
  2208. vec4 uvRegion = uvAtlasRegion;
  2209. uvRegion = mod(uvRegion + 65536.0, 65536.0);
  2210. uvRegion /= 65535.0;
  2211. vec2 atlasScale = uvRegion.zw - uvRegion.xy;
  2212. vec2 uvAtlas = fract(textureCoordinates) * atlasScale + uvRegion.xy;
  2213. float maxdUV = 0.125;
  2214. vec2 dUVdx = clamp(dFdx(textureCoordinates), -maxdUV, maxdUV) * atlasScale;
  2215. vec2 dUVdy = clamp(dFdy(textureCoordinates), -maxdUV, maxdUV) * atlasScale;
  2216. return texture2DGradEXT(tex, uvAtlas, dUVdx, dUVdy);
  2217. }
  2218. #endif
  2219. vec4 czm_getTexColorForS3M(sampler2D curTexture, vec3 oriTexCoord, float texTileWidth, float fMaxMipLev, float fTexCoordScale, vec2 vecTexCoordTranslate,float isRGBA, vec4 texUVoffset, out vec2 outTexCoord)
  2220. {
  2221. vec4 color = vec4(1.0);
  2222. if(oriTexCoord.z <= -99900.0){
  2223. return color;
  2224. }
  2225. float mipLevel = 0.0;
  2226. #ifdef GL_OES_standard_derivatives
  2227. CalculateMipLevel(oriTexCoord.xy, texTileWidth, fMaxMipLev, mipLevel);
  2228. #endif
  2229. vec2 realTexCoord;
  2230. CalculateTexCoord(oriTexCoord, fTexCoordScale, vecTexCoordTranslate.x, vecTexCoordTranslate.y, texTileWidth, mipLevel, realTexCoord);
  2231. if(isRGBA > 0.5)
  2232. {
  2233. vec2 rgbTexCoord;
  2234. rgbTexCoord.x = (realTexCoord.x + vecTexCoordTranslate.x * fTexCoordScale) * 0.5;
  2235. rgbTexCoord.y = (realTexCoord.y + vecTexCoordTranslate.y * fTexCoordScale) * 0.5;
  2236. rgbTexCoord.xy += texUVoffset.xy;
  2237. color = texture2D(curTexture, rgbTexCoord.xy, -10.0);
  2238. vec2 vecAlphaTexCoord;
  2239. vecAlphaTexCoord.x = rgbTexCoord.x;
  2240. vecAlphaTexCoord.y = rgbTexCoord.y + fTexCoordScale * 0.5;
  2241. vecAlphaTexCoord.xy += texUVoffset.xy;
  2242. color.a = texture2D(curTexture, vecAlphaTexCoord.xy, -10.0).r;
  2243. }
  2244. else
  2245. {
  2246. realTexCoord = realTexCoord * texUVoffset.zw + texUVoffset.xy;
  2247. if(oriTexCoord.z < -9000.0)
  2248. {
  2249. color = texture2D(curTexture, realTexCoord.xy);
  2250. }
  2251. else
  2252. {
  2253. #ifndef USE_UVRegion
  2254. #ifdef GL_EXT_shader_texture_lod
  2255. color = texture2DLodEXT(curTexture, realTexCoord.xy, mipLevel);
  2256. #else
  2257. #ifdef WEBEL2
  2258. color = textureLod(curTexture, realTexCoord.xy, mipLevel);
  2259. #else
  2260. color = texture2D(curTexture, realTexCoord.xy, mipLevel);
  2261. #endif
  2262. #endif
  2263. #else
  2264. color = textureAtlasLookup(curTexture, realTexCoord);
  2265. #endif
  2266. }
  2267. #ifdef RGBTOBGR
  2268. color = color.bgra;
  2269. #endif
  2270. }
  2271. outTexCoord = realTexCoord;
  2272. return color;
  2273. }
  2274. vec4 czm_getTexColorForS3M(sampler2D texture, vec2 uv, vec2 texDim, vec2 texTran, vec2 texScale, float maxMipLevel, out vec2 outTexCoord)
  2275. {
  2276. if(maxMipLevel < 0.0)
  2277. {
  2278. return vec4(1.0);
  2279. }
  2280. vec4 colorCeil = vec4(1.0);
  2281. float mipLevel = 0.0;
  2282. #ifdef GL_OES_standard_derivatives
  2283. CalculateMipLevel(uv, texDim, maxMipLevel, mipLevel);
  2284. #endif
  2285. float ceilMipLevel = ceil(mipLevel);
  2286. vec2 translate = vec2(texTran.x, texTran.y);
  2287. float temp;
  2288. if(ceilMipLevel > 0.0)
  2289. {
  2290. translate.x = texTran.x + texScale.x;
  2291. temp = pow(2.0, ceilMipLevel - 1.0);
  2292. translate.y = texTran.y + texScale.y * (temp - 1.0) / temp;
  2293. }
  2294. float scale = 1.0 / pow(2.0, ceilMipLevel);
  2295. vec2 texcoord = fract(uv);
  2296. float offsetX = pow(2.0, ceilMipLevel) / texDim.x;
  2297. float offsetY = pow(2.0, ceilMipLevel) / texDim.y;
  2298. texcoord.x = clamp(texcoord.x, 0.0 + offsetX, 1.0 - offsetX);
  2299. texcoord.y = clamp(texcoord.y, 0.0 + offsetY, 1.0 - offsetY);
  2300. texcoord.x = texcoord.x * texScale.x * scale + translate.x;
  2301. texcoord.y = texcoord.y * texScale.y * scale + translate.y;
  2302. #ifdef GL_EXT_shader_texture_lod
  2303. colorCeil = texture2DLodEXT(texture, texcoord.xy, 0.0);
  2304. #else
  2305. #ifdef WEBEL2
  2306. colorCeil = textureLod(texture, texcoord.xy, 0.0);
  2307. #else
  2308. colorCeil = texture2D(texture, texcoord.xy, -10.0);
  2309. #endif
  2310. #endif
  2311. vec4 colorFloor = vec4(1.0);
  2312. float floorMipLevel = floor(mipLevel);
  2313. translate = vec2(texTran.x, texTran.y);
  2314. if(floorMipLevel > 0.0)
  2315. {
  2316. translate.x = texTran.x + texScale.x;
  2317. temp = pow(2.0, floorMipLevel - 1.0);
  2318. translate.y = texTran.y + texScale.y * (temp - 1.0) / temp;
  2319. }
  2320. scale = 1.0 / pow(2.0, floorMipLevel);
  2321. texcoord = fract(uv);
  2322. offsetX = pow(2.0, floorMipLevel) / texDim.x;
  2323. offsetY = pow(2.0, floorMipLevel) / texDim.y;
  2324. texcoord.x = clamp(texcoord.x, 0.0 + offsetX, 1.0 - offsetX);
  2325. texcoord.y = clamp(texcoord.y, 0.0 + offsetY, 1.0 - offsetY);
  2326. texcoord.x = texcoord.x * texScale.x * scale + translate.x;
  2327. texcoord.y = texcoord.y * texScale.y * scale + translate.y;
  2328. #ifdef GL_EXT_shader_texture_lod
  2329. colorFloor = texture2DLodEXT(texture, texcoord.xy, 0.0);
  2330. #else
  2331. #ifdef WEBEL2
  2332. colorFloor = textureLod(texture, texcoord.xy, 0.0);
  2333. #else
  2334. colorFloor = texture2D(texture, texcoord.xy, -10.0);
  2335. #endif
  2336. #endif
  2337. vec4 color = colorCeil * 0.5 + colorFloor * 0.5;
  2338. return color;
  2339. }`;var to=`const int SHIFT_LEFT8 = 256;
  2340. void czm_getTextureMatrixFromZValue(in int nZ, inout float XTran, inout float YTran, inout float scale, inout float isRGBA)
  2341. {
  2342. if(nZ < 0){
  2343. return ;
  2344. }
  2345. int nDel8 = nZ / SHIFT_LEFT8;
  2346. int nDel16 = nDel8 / SHIFT_LEFT8;
  2347. YTran = float(nZ - nDel8 * SHIFT_LEFT8);
  2348. XTran = float(nDel8 - nDel16 * SHIFT_LEFT8);
  2349. int nLevel = nDel16;
  2350. scale = 1.0 / pow(2.0, float(nLevel));
  2351. }`;var oo=`uniform sampler2D uVolumeTexture;
  2352. #ifdef TIME_ORDER
  2353. uniform sampler2D uNextVolumeTexture;
  2354. uniform float uTimeRatio;
  2355. #endif
  2356. #ifdef Volume
  2357. uniform float width;
  2358. uniform float height;
  2359. uniform float depth;
  2360. uniform float sideBlockCount;
  2361. uniform float blockLength;
  2362. uniform float texLength;
  2363. uniform float uFilterMode;
  2364. #endif
  2365. float czm_unpackVolume(vec3 packedDepth)
  2366. {
  2367. return dot(packedDepth, vec3(1.0, 1.0 / 255.0, 1.0 / 65025.0));
  2368. }
  2369. #ifdef Volume
  2370. vec2 computeVolumeTextureCoord(vec3 texCoord, float fLevel)
  2371. {
  2372. float yOffset = floor((fLevel+0.25/sideBlockCount) / sideBlockCount);
  2373. float xOffset = fLevel - yOffset * sideBlockCount;
  2374. float texCoordV = (texCoord.y * height + yOffset * blockLength) / texLength;
  2375. float texCoordU = (texCoord.x * width + xOffset * blockLength) / texLength;
  2376. return vec2(texCoordU, texCoordV);
  2377. }
  2378. float computeVolumeValue(sampler2D volumeTexture, vec2 topTexCoord, vec2 bottomTexCoord, float ratio, out float noValue)
  2379. {
  2380. vec4 volumeValue1 = texture2D(volumeTexture, topTexCoord);
  2381. vec4 volumeValue2 = texture2D(volumeTexture, bottomTexCoord);
  2382. float fValue1 = clamp(czm_unpackVolume(volumeValue1.xyz),0.0,1.0);
  2383. float fValue2 = clamp(czm_unpackVolume(volumeValue2.xyz),0.0,1.0);
  2384. if(uFilterMode >0.5)
  2385. {
  2386. if(ratio<0.5)
  2387. {
  2388. ratio = 0.0;
  2389. }
  2390. else
  2391. {
  2392. ratio = 1.0;
  2393. }
  2394. }
  2395. noValue = mix(volumeValue1.a, volumeValue2.a, ratio);
  2396. if(volumeValue1.a < 0.5)
  2397. {
  2398. fValue1 = fValue2;
  2399. }
  2400. if(volumeValue2.a < 0.5)
  2401. {
  2402. fValue2 = fValue1;
  2403. }
  2404. return mix(fValue1, fValue2, ratio);
  2405. }
  2406. float czm_getVolumeValue(vec3 texCoord, out float noValue)
  2407. {
  2408. float fLevel = (depth - 1.0) * texCoord.z;
  2409. float bottomLevel= floor(fLevel);
  2410. float topLevel = bottomLevel + 1.0;
  2411. float ratio = topLevel - fLevel;
  2412. vec2 topTexCoord = computeVolumeTextureCoord(texCoord, topLevel);
  2413. vec2 bottomTexCoord = computeVolumeTextureCoord(texCoord, bottomLevel);
  2414. float fResult = computeVolumeValue(uVolumeTexture, topTexCoord, bottomTexCoord, ratio, noValue);
  2415. #ifdef TIME_ORDER
  2416. float fNextResult = computeVolumeValue(uNextVolumeTexture, topTexCoord, bottomTexCoord, ratio, noValue);
  2417. fResult = mix(fResult, fNextResult, uTimeRatio);
  2418. #endif
  2419. return fResult;
  2420. }
  2421. vec4 czm_getVolumeValue(vec3 texCoord)
  2422. {
  2423. float fLevel = (depth - 1.0) * texCoord.z;
  2424. float bottomLevel= floor(fLevel);
  2425. float topLevel = bottomLevel + 1.0;
  2426. float ratio = topLevel - fLevel;
  2427. float yOffset1 = floor((topLevel+0.25/sideBlockCount) / sideBlockCount);
  2428. float xOffset1 = topLevel - yOffset1 * sideBlockCount;
  2429. float texCoordV1 = (texCoord.y * height + yOffset1 * blockLength)/texLength;
  2430. float texCoordU1 = (texCoord.x * width + xOffset1 * blockLength)/texLength;
  2431. vec4 volumeColor1 = texture2D(uVolumeTexture, vec2(texCoordU1,texCoordV1));
  2432. float yOffset2 = floor((bottomLevel+0.25/sideBlockCount) / sideBlockCount);
  2433. float xOffset2 = bottomLevel - yOffset2 * sideBlockCount;
  2434. float texCoordV2 = (texCoord.y * height + yOffset2 * blockLength)/texLength;
  2435. float texCoordU2 = (texCoord.x * width + xOffset2 * blockLength)/texLength;
  2436. vec4 volumeColor2 = texture2D(uVolumeTexture, vec2(texCoordU2, texCoordV2));
  2437. if(uFilterMode >0.5)
  2438. {
  2439. if(ratio<0.5)
  2440. {
  2441. ratio = 0.0;
  2442. }
  2443. else
  2444. {
  2445. ratio = 1.0;
  2446. }
  2447. }
  2448. vec4 volumeColor = mix(volumeColor1, volumeColor2, ratio);
  2449. return volumeColor;
  2450. }
  2451. #endif`;var ro=`uniform sampler2D uVolumeTexture1;
  2452. uniform sampler2D uVolumeTexture2;
  2453. uniform sampler2D uVolumeTexture3;
  2454. uniform mat4 uMultiResolutionPara1;
  2455. /*
  2456. {uMultiResolutionTranslation1
  2457. 0.0, 0.0, 0.0, 0.0,
  2458. width1,height1,sideBlockCount1,blockLength1
  2459. texLength1, 0.0, 0.0, 0.0};
  2460. */
  2461. uniform mat4 uMultiResolutionPara2;
  2462. uniform mat4 uMultiResolutionPara3;
  2463. #ifdef TIME_ORDER
  2464. uniform sampler2D uNextVolumeTexture1;
  2465. uniform sampler2D uNextVolumeTexture2;
  2466. uniform sampler2D uNextVolumeTexture3;
  2467. #endif
  2468. #ifdef Volume
  2469. vec2 computeVolumeTextureCoord(vec2 texCoord, float fLevel, float texWidth, float texHeight, float texSideBlockCount, float texBlockLength, float texTotalLength)
  2470. {
  2471. float yOffset = floor((fLevel+0.25/texSideBlockCount) / texSideBlockCount);
  2472. float xOffset = fLevel - yOffset * texSideBlockCount;
  2473. float texCoordV = (texCoord.y * texHeight + yOffset * texBlockLength) / texTotalLength;
  2474. float texCoordU = (texCoord.x * texWidth + xOffset * texBlockLength) / texTotalLength;
  2475. return vec2(texCoordU, texCoordV);
  2476. }
  2477. float czm_getVolumeValueMultiResolution(vec3 texCoord, out float noValue)
  2478. {
  2479. float fLevel = (depth - 1.0) * texCoord.z;
  2480. float bottomLevel= floor(fLevel);
  2481. float topLevel = bottomLevel + 1.0;
  2482. float ratio = topLevel - fLevel;
  2483. vec2 topTexCoord = computeVolumeTextureCoord(texCoord, topLevel);
  2484. vec2 bottomTexCoord = computeVolumeTextureCoord(texCoord, bottomLevel);
  2485. float fResult = computeVolumeValue(uVolumeTexture, topTexCoord, bottomTexCoord, ratio, noValue);
  2486. #ifdef TIME_ORDER
  2487. float fNextResult = computeVolumeValue(uNextVolumeTexture, topTexCoord, bottomTexCoord, ratio, noValue);
  2488. fResult = mix(fResult, fNextResult, uTimeRatio);
  2489. #endif
  2490. float width = uMultiResolutionPara1[2].x;
  2491. float height = uMultiResolutionPara1[2].y;
  2492. float sideBlockCount = uMultiResolutionPara1[2].z;
  2493. float blockLength = uMultiResolutionPara1[2].w;
  2494. float texLength = uMultiResolutionPara1[3].x;
  2495. vec4 uMultiResolutionTranslation = uMultiResolutionPara1[0];
  2496. vec2 texCoord1 = (texCoord.xy - uMultiResolutionTranslation.xy) * uMultiResolutionTranslation.zw;
  2497. vec2 topTexCoord1 = computeVolumeTextureCoord(texCoord1, topLevel, width, height, sideBlockCount, blockLength, texLength);
  2498. vec2 bottomTexCoord1 = computeVolumeTextureCoord(texCoord1, bottomLevel, width, height, sideBlockCount, blockLength, texLength);
  2499. float alpha1 = 5.0 * clamp( max(abs(texCoord1.x - 0.5), abs(texCoord1.y - 0.5)) - 0.3,0.0,0.2);
  2500. float fResult1 = computeVolumeValue(uVolumeTexture1, topTexCoord1, bottomTexCoord1, ratio, noValue);
  2501. #ifdef TIME_ORDER
  2502. float fNextResult1 = computeVolumeValue(uNextVolumeTexture1, topTexCoord1, bottomTexCoord1, ratio, noValue);
  2503. fResult1 = mix(fResult1, fNextResult1, uTimeRatio);
  2504. #endif
  2505. width = uMultiResolutionPara2[2].x;
  2506. height = uMultiResolutionPara2[2].y;
  2507. sideBlockCount = uMultiResolutionPara2[2].z;
  2508. blockLength = uMultiResolutionPara2[2].w;
  2509. texLength = uMultiResolutionPara2[3].x;
  2510. uMultiResolutionTranslation = uMultiResolutionPara2[0];
  2511. vec2 texCoord2 = (texCoord.xy - uMultiResolutionTranslation.xy) * uMultiResolutionTranslation.zw;
  2512. vec2 topTexCoord2 = computeVolumeTextureCoord(texCoord2, topLevel, width, height, sideBlockCount, blockLength, texLength);
  2513. vec2 bottomTexCoord2 = computeVolumeTextureCoord(texCoord2, bottomLevel, width, height, sideBlockCount, blockLength, texLength);
  2514. float alpha2 = 5.0 * clamp( max(abs(texCoord2.x - 0.5), abs(texCoord2.y - 0.5)) - 0.3,0.0,0.2);
  2515. float fResult2 = computeVolumeValue(uVolumeTexture2, topTexCoord2, bottomTexCoord2, ratio, noValue);
  2516. #ifdef TIME_ORDER
  2517. float fNextResult2 = computeVolumeValue(uNextVolumeTexture2, topTexCoord2, bottomTexCoord2, ratio, noValue);
  2518. fResult2 = mix(fResult2, fNextResult2, uTimeRatio);
  2519. #endif
  2520. width = uMultiResolutionPara3[2].x;
  2521. height = uMultiResolutionPara3[2].y;
  2522. sideBlockCount = uMultiResolutionPara3[2].z;
  2523. blockLength = uMultiResolutionPara3[2].w;
  2524. texLength = uMultiResolutionPara3[3].x;
  2525. uMultiResolutionTranslation = uMultiResolutionPara3[0];
  2526. vec2 texCoord3 = (texCoord.xy - uMultiResolutionTranslation.xy) * uMultiResolutionTranslation.zw;
  2527. vec2 topTexCoord3 = computeVolumeTextureCoord(texCoord3, topLevel, width, height, sideBlockCount, blockLength, texLength);
  2528. vec2 bottomTexCoord3 = computeVolumeTextureCoord(texCoord3, bottomLevel, width, height, sideBlockCount, blockLength, texLength);
  2529. float alpha3 = 5.0 * clamp( max(abs(texCoord3.x - 0.5), abs(texCoord3.y - 0.5)) - 0.3,0.0,0.2);
  2530. float fResult3 = computeVolumeValue(uVolumeTexture3, topTexCoord3, bottomTexCoord3, ratio, noValue);
  2531. #ifdef TIME_ORDER
  2532. float fNextResult3 = computeVolumeValue(uNextVolumeTexture3, topTexCoord3, bottomTexCoord3, ratio, noValue);
  2533. fResult3 = mix(fResult3, fNextResult3, uTimeRatio);
  2534. #endif
  2535. //return mix(fResult2, mix(fResult1, fResult, alpha1), alpha2);
  2536. return mix(fResult3, mix(fResult2, mix(fResult1, fResult, alpha1), alpha2), alpha3);
  2537. }
  2538. #endif`;var io=`/**
  2539. * @private
  2540. */
  2541. vec4 czm_getWaterNoise(sampler2D normalMap, vec2 uv, float time, float angleInRadians)
  2542. {
  2543. float cosAngle = cos(angleInRadians);
  2544. float sinAngle = sin(angleInRadians);
  2545. // time dependent sampling directions
  2546. vec2 s0 = vec2(1.0/17.0, 0.0);
  2547. vec2 s1 = vec2(-1.0/29.0, 0.0);
  2548. vec2 s2 = vec2(1.0/101.0, 1.0/59.0);
  2549. vec2 s3 = vec2(-1.0/109.0, -1.0/57.0);
  2550. // rotate sampling direction by specified angle
  2551. s0 = vec2((cosAngle * s0.x) - (sinAngle * s0.y), (sinAngle * s0.x) + (cosAngle * s0.y));
  2552. s1 = vec2((cosAngle * s1.x) - (sinAngle * s1.y), (sinAngle * s1.x) + (cosAngle * s1.y));
  2553. s2 = vec2((cosAngle * s2.x) - (sinAngle * s2.y), (sinAngle * s2.x) + (cosAngle * s2.y));
  2554. s3 = vec2((cosAngle * s3.x) - (sinAngle * s3.y), (sinAngle * s3.x) + (cosAngle * s3.y));
  2555. vec2 uv0 = (uv/103.0) + (time * s0);
  2556. vec2 uv1 = uv/107.0 + (time * s1) + vec2(0.23);
  2557. vec2 uv2 = uv/vec2(897.0, 983.0) + (time * s2) + vec2(0.51);
  2558. vec2 uv3 = uv/vec2(991.0, 877.0) + (time * s3) + vec2(0.71);
  2559. uv0 = fract(uv0);
  2560. uv1 = fract(uv1);
  2561. uv2 = fract(uv2);
  2562. uv3 = fract(uv3);
  2563. vec4 noise = (texture2D(normalMap, uv0)) +
  2564. (texture2D(normalMap, uv1)) +
  2565. (texture2D(normalMap, uv2)) +
  2566. (texture2D(normalMap, uv3));
  2567. // average and scale to between -1 and 1
  2568. return ((noise / 4.0) - 0.5) * 2.0;
  2569. }
  2570. `;var ao=`/**
  2571. * Returns the WGS84 ellipsoid, with its center at the origin of world coordinates, in eye coordinates.
  2572. *
  2573. * @name czm_getWgs84EllipsoidEC
  2574. * @glslFunction
  2575. *
  2576. * @returns {czm_ellipsoid} The WGS84 ellipsoid, with its center at the origin of world coordinates, in eye coordinates.
  2577. *
  2578. * @see Ellipsoid.WGS84
  2579. *
  2580. * @example
  2581. * czm_ellipsoid ellipsoid = czm_getWgs84EllipsoidEC();
  2582. */
  2583. czm_ellipsoid czm_getWgs84EllipsoidEC()
  2584. {
  2585. vec3 radii = vec3(6378137.0, 6378137.0, 6378137.0);
  2586. vec3 inverseRadii = vec3(1.0 / radii.x, 1.0 / radii.y, 1.0 / radii.z);
  2587. vec3 inverseRadiiSquared = inverseRadii * inverseRadii;
  2588. czm_ellipsoid temp = czm_ellipsoid(czm_view[3].xyz, radii, inverseRadii, inverseRadiiSquared);
  2589. return temp;
  2590. }
  2591. `;var lo=`/**
  2592. * Converts an HSB color (hue, saturation, brightness) to RGB
  2593. * HSB <-> RGB conversion with minimal branching:
  2594. *
  2595. * @name czm_HSBToRGB
  2596. * @glslFunction
  2597. *
  2598. * @param {vec3} hsb The color in HSB.
  2599. *
  2600. * @returns {vec3} The color in RGB.
  2601. *
  2602. * @example
  2603. * vec3 hsb = czm_RGBToHSB(rgb);
  2604. * hsb.z *= 0.1;
  2605. * rgb = czm_HSBToRGB(hsb);
  2606. */
  2607. const vec4 K_HSB2RGB = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
  2608. vec3 czm_HSBToRGB(vec3 hsb)
  2609. {
  2610. vec3 p = abs(fract(hsb.xxx + K_HSB2RGB.xyz) * 6.0 - K_HSB2RGB.www);
  2611. return hsb.z * mix(K_HSB2RGB.xxx, clamp(p - K_HSB2RGB.xxx, 0.0, 1.0), hsb.y);
  2612. }
  2613. `;var co=`/**
  2614. * Converts an HSL color (hue, saturation, lightness) to RGB
  2615. * HSL <-> RGB conversion:
  2616. *
  2617. * @name czm_HSLToRGB
  2618. * @glslFunction
  2619. *
  2620. * @param {vec3} rgb The color in HSL.
  2621. *
  2622. * @returns {vec3} The color in RGB.
  2623. *
  2624. * @example
  2625. * vec3 hsl = czm_RGBToHSL(rgb);
  2626. * hsl.z *= 0.1;
  2627. * rgb = czm_HSLToRGB(hsl);
  2628. */
  2629. vec3 hueToRGB(float hue)
  2630. {
  2631. float r = abs(hue * 6.0 - 3.0) - 1.0;
  2632. float g = 2.0 - abs(hue * 6.0 - 2.0);
  2633. float b = 2.0 - abs(hue * 6.0 - 4.0);
  2634. return clamp(vec3(r, g, b), 0.0, 1.0);
  2635. }
  2636. vec3 czm_HSLToRGB(vec3 hsl)
  2637. {
  2638. vec3 rgb = hueToRGB(hsl.x);
  2639. float c = (1.0 - abs(2.0 * hsl.z - 1.0)) * hsl.y;
  2640. return (rgb - 0.5) * c + hsl.z;
  2641. }
  2642. `;var so=`/**
  2643. * Adjusts the hue of a color.
  2644. *
  2645. * @name czm_hue
  2646. * @glslFunction
  2647. *
  2648. * @param {vec3} rgb The color.
  2649. * @param {float} adjustment The amount to adjust the hue of the color in radians.
  2650. *
  2651. * @returns {float} The color with the hue adjusted.
  2652. *
  2653. * @example
  2654. * vec3 adjustHue = czm_hue(color, czm_pi); // The same as czm_hue(color, -czm_pi)
  2655. */
  2656. vec3 czm_hue(vec3 rgb, float adjustment)
  2657. {
  2658. const mat3 toYIQ = mat3(0.299, 0.587, 0.114,
  2659. 0.595716, -0.274453, -0.321263,
  2660. 0.211456, -0.522591, 0.311135);
  2661. const mat3 toRGB = mat3(1.0, 0.9563, 0.6210,
  2662. 1.0, -0.2721, -0.6474,
  2663. 1.0, -1.107, 1.7046);
  2664. vec3 yiq = toYIQ * rgb;
  2665. float hue = atan(yiq.z, yiq.y) + adjustment;
  2666. float chroma = sqrt(yiq.z * yiq.z + yiq.y * yiq.y);
  2667. vec3 color = vec3(yiq.x, chroma * cos(hue), chroma * sin(hue));
  2668. return toRGB * color;
  2669. }
  2670. `;var fo=`/**
  2671. * Converts a color in linear space to RGB space.
  2672. *
  2673. * @name czm_inverseGamma
  2674. * @glslFunction
  2675. *
  2676. * @param {vec3} color The color in linear space.
  2677. * @returns {vec3} The color in RGB space.
  2678. */
  2679. vec3 czm_inverseGamma(vec3 color) {
  2680. return pow(color, vec3(1.0 / czm_gamma));
  2681. }
  2682. `;var uo=`mat3 czm_inverseMatrix(mat3 m)
  2683. {
  2684. float Determinant =
  2685. m[0][0] * (m[1][1] * m[2][2] - m[2][1] * m[1][2])
  2686. - m[1][0] * (m[0][1] * m[2][2] - m[2][1] * m[0][2])
  2687. + m[2][0] * (m[0][1] * m[1][2] - m[1][1] * m[0][2]);
  2688. mat3 Inverse;
  2689. Inverse[0][0] = + (m[1][1] * m[2][2] - m[2][1] * m[1][2]);
  2690. Inverse[1][0] = - (m[1][0] * m[2][2] - m[2][0] * m[1][2]);
  2691. Inverse[2][0] = + (m[1][0] * m[2][1] - m[2][0] * m[1][1]);
  2692. Inverse[0][1] = - (m[0][1] * m[2][2] - m[2][1] * m[0][2]);
  2693. Inverse[1][1] = + (m[0][0] * m[2][2] - m[2][0] * m[0][2]);
  2694. Inverse[2][1] = - (m[0][0] * m[2][1] - m[2][0] * m[0][1]);
  2695. Inverse[0][2] = + (m[0][1] * m[1][2] - m[1][1] * m[0][2]);
  2696. Inverse[1][2] = - (m[0][0] * m[1][2] - m[1][0] * m[0][2]);
  2697. Inverse[2][2] = + (m[0][0] * m[1][1] - m[1][0] * m[0][1]);
  2698. Inverse /= Determinant;
  2699. return Inverse;
  2700. }
  2701. mat4 czm_inverseMatrix(mat4 m)
  2702. {
  2703. float Coef00 = m[2][2] * m[3][3] - m[3][2] * m[2][3];
  2704. float Coef02 = m[1][2] * m[3][3] - m[3][2] * m[1][3];
  2705. float Coef03 = m[1][2] * m[2][3] - m[2][2] * m[1][3];
  2706. float Coef04 = m[2][1] * m[3][3] - m[3][1] * m[2][3];
  2707. float Coef06 = m[1][1] * m[3][3] - m[3][1] * m[1][3];
  2708. float Coef07 = m[1][1] * m[2][3] - m[2][1] * m[1][3];
  2709. float Coef08 = m[2][1] * m[3][2] - m[3][1] * m[2][2];
  2710. float Coef10 = m[1][1] * m[3][2] - m[3][1] * m[1][2];
  2711. float Coef11 = m[1][1] * m[2][2] - m[2][1] * m[1][2];
  2712. float Coef12 = m[2][0] * m[3][3] - m[3][0] * m[2][3];
  2713. float Coef14 = m[1][0] * m[3][3] - m[3][0] * m[1][3];
  2714. float Coef15 = m[1][0] * m[2][3] - m[2][0] * m[1][3];
  2715. float Coef16 = m[2][0] * m[3][2] - m[3][0] * m[2][2];
  2716. float Coef18 = m[1][0] * m[3][2] - m[3][0] * m[1][2];
  2717. float Coef19 = m[1][0] * m[2][2] - m[2][0] * m[1][2];
  2718. float Coef20 = m[2][0] * m[3][1] - m[3][0] * m[2][1];
  2719. float Coef22 = m[1][0] * m[3][1] - m[3][0] * m[1][1];
  2720. float Coef23 = m[1][0] * m[2][1] - m[2][0] * m[1][1];
  2721. const vec4 SignA = vec4( 1.0, -1.0, 1.0, -1.0);
  2722. const vec4 SignB = vec4(-1.0, 1.0, -1.0, 1.0);
  2723. vec4 Fac0 = vec4(Coef00, Coef00, Coef02, Coef03);
  2724. vec4 Fac1 = vec4(Coef04, Coef04, Coef06, Coef07);
  2725. vec4 Fac2 = vec4(Coef08, Coef08, Coef10, Coef11);
  2726. vec4 Fac3 = vec4(Coef12, Coef12, Coef14, Coef15);
  2727. vec4 Fac4 = vec4(Coef16, Coef16, Coef18, Coef19);
  2728. vec4 Fac5 = vec4(Coef20, Coef20, Coef22, Coef23);
  2729. vec4 Vec0 = vec4(m[1][0], m[0][0], m[0][0], m[0][0]);
  2730. vec4 Vec1 = vec4(m[1][1], m[0][1], m[0][1], m[0][1]);
  2731. vec4 Vec2 = vec4(m[1][2], m[0][2], m[0][2], m[0][2]);
  2732. vec4 Vec3 = vec4(m[1][3], m[0][3], m[0][3], m[0][3]);
  2733. vec4 Inv0 = SignA * (Vec1 * Fac0 - Vec2 * Fac1 + Vec3 * Fac2);
  2734. vec4 Inv1 = SignB * (Vec0 * Fac0 - Vec2 * Fac3 + Vec3 * Fac4);
  2735. vec4 Inv2 = SignA * (Vec0 * Fac1 - Vec1 * Fac3 + Vec3 * Fac5);
  2736. vec4 Inv3 = SignB * (Vec0 * Fac2 - Vec1 * Fac4 + Vec2 * Fac5);
  2737. mat4 Inverse = mat4(Inv0, Inv1, Inv2, Inv3);
  2738. vec4 Row0 = vec4(Inverse[0][0], Inverse[1][0], Inverse[2][0], Inverse[3][0]);
  2739. float Determinant = dot(m[0], Row0);
  2740. Inverse /= Determinant;
  2741. return Inverse;
  2742. }
  2743. `;var mo=`/**
  2744. * Determines if a time interval is empty.
  2745. *
  2746. * @name czm_isEmpty
  2747. * @glslFunction
  2748. *
  2749. * @param {czm_raySegment} interval The interval to test.
  2750. *
  2751. * @returns {bool} <code>true</code> if the time interval is empty; otherwise, <code>false</code>.
  2752. *
  2753. * @example
  2754. * bool b0 = czm_isEmpty(czm_emptyRaySegment); // true
  2755. * bool b1 = czm_isEmpty(czm_raySegment(0.0, 1.0)); // false
  2756. * bool b2 = czm_isEmpty(czm_raySegment(1.0, 1.0)); // false, contains 1.0.
  2757. */
  2758. bool czm_isEmpty(czm_raySegment interval)
  2759. {
  2760. return (interval.stop < 0.0);
  2761. }
  2762. `;var po=`/**
  2763. * Determines if a time interval is empty.
  2764. *
  2765. * @name czm_isFull
  2766. * @glslFunction
  2767. *
  2768. * @param {czm_raySegment} interval The interval to test.
  2769. *
  2770. * @returns {bool} <code>true</code> if the time interval is empty; otherwise, <code>false</code>.
  2771. *
  2772. * @example
  2773. * bool b0 = czm_isEmpty(czm_emptyRaySegment); // true
  2774. * bool b1 = czm_isEmpty(czm_raySegment(0.0, 1.0)); // false
  2775. * bool b2 = czm_isEmpty(czm_raySegment(1.0, 1.0)); // false, contains 1.0.
  2776. */
  2777. bool czm_isFull(czm_raySegment interval)
  2778. {
  2779. return (interval.start == 0.0 && interval.stop == czm_infinity);
  2780. }
  2781. `;var vo=`/**
  2782. * Computes the fraction of a Web Wercator rectangle at which a given geodetic latitude is located.
  2783. *
  2784. * @name czm_latitudeToWebMercatorFraction
  2785. * @glslFunction
  2786. *
  2787. * @param {float} latitude The geodetic latitude, in radians.
  2788. * @param {float} southMercatorY The Web Mercator coordinate of the southern boundary of the rectangle.
  2789. * @param {float} oneOverMercatorHeight The total height of the rectangle in Web Mercator coordinates.
  2790. *
  2791. * @returns {float} The fraction of the rectangle at which the latitude occurs. If the latitude is the southern
  2792. * boundary of the rectangle, the return value will be zero. If it is the northern boundary, the return
  2793. * value will be 1.0. Latitudes in between are mapped according to the Web Mercator projection.
  2794. */
  2795. float czm_latitudeToWebMercatorFraction(float latitude, float southMercatorY, float oneOverMercatorHeight)
  2796. {
  2797. float sinLatitude = sin(latitude);
  2798. float mercatorY = 0.5 * log((1.0 + sinLatitude) / (1.0 - sinLatitude));
  2799. return (mercatorY - southMercatorY) * oneOverMercatorHeight;
  2800. }
  2801. `;var ho=`/**
  2802. * Computes distance from an point in 2D to a line in 2D.
  2803. *
  2804. * @name czm_lineDistance
  2805. * @glslFunction
  2806. *
  2807. * param {vec2} point1 A point along the line.
  2808. * param {vec2} point2 A point along the line.
  2809. * param {vec2} point A point that may or may not be on the line.
  2810. * returns {float} The distance from the point to the line.
  2811. */
  2812. float czm_lineDistance(vec2 point1, vec2 point2, vec2 point) {
  2813. return abs((point2.y - point1.y) * point.x - (point2.x - point1.x) * point.y + point2.x * point1.y - point2.y * point1.x) / distance(point2, point1);
  2814. }
  2815. `;var go=`/**
  2816. * Computes the luminance of a color.
  2817. *
  2818. * @name czm_luminance
  2819. * @glslFunction
  2820. *
  2821. * @param {vec3} rgb The color.
  2822. *
  2823. * @returns {float} The luminance.
  2824. *
  2825. * @example
  2826. * float light = czm_luminance(vec3(0.0)); // 0.0
  2827. * float dark = czm_luminance(vec3(1.0)); // ~1.0
  2828. */
  2829. float czm_luminance(vec3 rgb)
  2830. {
  2831. // Algorithm from Chapter 10 of Graphics Shaders.
  2832. const vec3 W = vec3(0.2125, 0.7154, 0.0721);
  2833. return dot(rgb, W);
  2834. }
  2835. `;var _o=`/**
  2836. * Computes the size of a pixel in meters at a distance from the eye.
  2837. * <p>
  2838. * Use this version when passing in a custom pixel ratio. For example, passing in 1.0 will return meters per native device pixel.
  2839. * </p>
  2840. * @name czm_metersPerPixel
  2841. * @glslFunction
  2842. *
  2843. * @param {vec3} positionEC The position to get the meters per pixel in eye coordinates.
  2844. * @param {float} pixelRatio The scaling factor from pixel space to coordinate space
  2845. *
  2846. * @returns {float} The meters per pixel at positionEC.
  2847. */
  2848. float czm_metersPerPixel(vec4 positionEC, float pixelRatio)
  2849. {
  2850. float width = czm_viewport.z;
  2851. float height = czm_viewport.w;
  2852. float pixelWidth;
  2853. float pixelHeight;
  2854. float top = czm_frustumPlanes.x;
  2855. float bottom = czm_frustumPlanes.y;
  2856. float left = czm_frustumPlanes.z;
  2857. float right = czm_frustumPlanes.w;
  2858. if (czm_sceneMode == czm_sceneMode2D || czm_orthographicIn3D == 1.0)
  2859. {
  2860. float frustumWidth = right - left;
  2861. float frustumHeight = top - bottom;
  2862. pixelWidth = frustumWidth / width;
  2863. pixelHeight = frustumHeight / height;
  2864. }
  2865. else
  2866. {
  2867. float distanceToPixel = -positionEC.z;
  2868. float inverseNear = 1.0 / czm_currentFrustum.x;
  2869. float tanTheta = top * inverseNear;
  2870. pixelHeight = 2.0 * distanceToPixel * tanTheta / height;
  2871. tanTheta = right * inverseNear;
  2872. pixelWidth = 2.0 * distanceToPixel * tanTheta / width;
  2873. }
  2874. return max(pixelWidth, pixelHeight) * pixelRatio;
  2875. }
  2876. /**
  2877. * Computes the size of a pixel in meters at a distance from the eye.
  2878. * <p>
  2879. * Use this version when scaling by pixel ratio.
  2880. * </p>
  2881. * @name czm_metersPerPixel
  2882. * @glslFunction
  2883. *
  2884. * @param {vec3} positionEC The position to get the meters per pixel in eye coordinates.
  2885. *
  2886. * @returns {float} The meters per pixel at positionEC.
  2887. */
  2888. float czm_metersPerPixel(vec4 positionEC)
  2889. {
  2890. return czm_metersPerPixel(positionEC, czm_pixelRatio);
  2891. }
  2892. `;var xo=`/**
  2893. * Transforms a position from model to window coordinates. The transformation
  2894. * from model to clip coordinates is done using {@link czm_modelViewProjection}.
  2895. * The transform from normalized device coordinates to window coordinates is
  2896. * done using {@link czm_viewportTransformation}, which assumes a depth range
  2897. * of <code>near = 0</code> and <code>far = 1</code>.
  2898. * <br /><br />
  2899. * This transform is useful when there is a need to manipulate window coordinates
  2900. * in a vertex shader as done by {@link BillboardCollection}.
  2901. * <br /><br />
  2902. * This function should not be confused with {@link czm_viewportOrthographic},
  2903. * which is an orthographic projection matrix that transforms from window
  2904. * coordinates to clip coordinates.
  2905. *
  2906. * @name czm_modelToWindowCoordinates
  2907. * @glslFunction
  2908. *
  2909. * @param {vec4} position The position in model coordinates to transform.
  2910. *
  2911. * @returns {vec4} The transformed position in window coordinates.
  2912. *
  2913. * @see czm_eyeToWindowCoordinates
  2914. * @see czm_modelViewProjection
  2915. * @see czm_viewportTransformation
  2916. * @see czm_viewportOrthographic
  2917. * @see BillboardCollection
  2918. *
  2919. * @example
  2920. * vec4 positionWC = czm_modelToWindowCoordinates(positionMC);
  2921. */
  2922. vec4 czm_modelToWindowCoordinates(vec4 position)
  2923. {
  2924. vec4 q = czm_modelViewProjection * position; // clip coordinates
  2925. q.xyz /= q.w; // normalized device coordinates
  2926. q.xyz = (czm_viewportTransformation * vec4(q.xyz, 1.0)).xyz; // window coordinates
  2927. return q;
  2928. }
  2929. `;var Co=`/**
  2930. * DOC_TBA
  2931. *
  2932. * @name czm_multiplyWithColorBalance
  2933. * @glslFunction
  2934. */
  2935. vec3 czm_multiplyWithColorBalance(vec3 left, vec3 right)
  2936. {
  2937. // Algorithm from Chapter 10 of Graphics Shaders.
  2938. const vec3 W = vec3(0.2125, 0.7154, 0.0721);
  2939. vec3 target = left * right;
  2940. float leftLuminance = dot(left, W);
  2941. float rightLuminance = dot(right, W);
  2942. float targetLuminance = dot(target, W);
  2943. return ((leftLuminance + rightLuminance) / (2.0 * targetLuminance)) * target;
  2944. }
  2945. `;var To=`/**
  2946. * Computes a value that scales with distance. The scaling is clamped at the near and
  2947. * far distances, and does not extrapolate. This function works with the
  2948. * {@link NearFarScalar} JavaScript class.
  2949. *
  2950. * @name czm_nearFarScalar
  2951. * @glslFunction
  2952. *
  2953. * @param {vec4} nearFarScalar A vector with 4 components: Near distance (x), Near value (y), Far distance (z), Far value (w).
  2954. * @param {float} cameraDistSq The square of the current distance from the camera.
  2955. *
  2956. * @returns {float} The value at this distance.
  2957. */
  2958. float czm_nearFarScalar(vec4 nearFarScalar, float cameraDistSq)
  2959. {
  2960. float valueAtMin = nearFarScalar.y;
  2961. float valueAtMax = nearFarScalar.w;
  2962. float nearDistanceSq = nearFarScalar.x * nearFarScalar.x;
  2963. float farDistanceSq = nearFarScalar.z * nearFarScalar.z;
  2964. float t = (cameraDistSq - nearDistanceSq) / (farDistanceSq - nearDistanceSq);
  2965. t = pow(clamp(t, 0.0, 1.0), 0.2);
  2966. return mix(valueAtMin, valueAtMax, t);
  2967. }
  2968. `;var yo=` /**
  2969. * Decodes a unit-length vector in 'oct' encoding to a normalized 3-component Cartesian vector.
  2970. * The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors",
  2971. * Cigolle et al 2014:
  2972. *
  2973. * @name czm_octDecode
  2974. * @param {vec2} encoded The oct-encoded, unit-length vector
  2975. * @param {float} range The maximum value of the SNORM range. The encoded vector is stored in log2(rangeMax+1) bits.
  2976. * @returns {vec3} The decoded and normalized vector
  2977. */
  2978. vec3 czm_octDecode(vec2 encoded, float range)
  2979. {
  2980. if (encoded.x == 0.0 && encoded.y == 0.0) {
  2981. return vec3(0.0, 0.0, 0.0);
  2982. }
  2983. encoded = encoded / range * 2.0 - 1.0;
  2984. vec3 v = vec3(encoded.x, encoded.y, 1.0 - abs(encoded.x) - abs(encoded.y));
  2985. if (v.z < 0.0)
  2986. {
  2987. v.xy = (1.0 - abs(v.yx)) * czm_signNotZero(v.xy);
  2988. }
  2989. return normalize(v);
  2990. }
  2991. /**
  2992. * Decodes a unit-length vector in 'oct' encoding to a normalized 3-component Cartesian vector.
  2993. * The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors",
  2994. * Cigolle et al 2014:
  2995. *
  2996. * @name czm_octDecode
  2997. * @param {vec2} encoded The oct-encoded, unit-length vector
  2998. * @returns {vec3} The decoded and normalized vector
  2999. */
  3000. vec3 czm_octDecode(vec2 encoded)
  3001. {
  3002. return czm_octDecode(encoded, 255.0);
  3003. }
  3004. /**
  3005. * Decodes a unit-length vector in 'oct' encoding packed into a floating-point number to a normalized 3-component Cartesian vector.
  3006. * The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors",
  3007. * Cigolle et al 2014:
  3008. *
  3009. * @name czm_octDecode
  3010. * @param {float} encoded The oct-encoded, unit-length vector
  3011. * @returns {vec3} The decoded and normalized vector
  3012. */
  3013. vec3 czm_octDecode(float encoded)
  3014. {
  3015. float temp = encoded / 256.0;
  3016. float x = floor(temp);
  3017. float y = (temp - x) * 256.0;
  3018. return czm_octDecode(vec2(x, y));
  3019. }
  3020. /**
  3021. * Decodes three unit-length vectors in 'oct' encoding packed into two floating-point numbers to normalized 3-component Cartesian vectors.
  3022. * The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors",
  3023. * Cigolle et al 2014:
  3024. *
  3025. * @name czm_octDecode
  3026. * @param {vec2} encoded The packed oct-encoded, unit-length vectors.
  3027. * @param {vec3} vector1 One decoded and normalized vector.
  3028. * @param {vec3} vector2 One decoded and normalized vector.
  3029. * @param {vec3} vector3 One decoded and normalized vector.
  3030. */
  3031. void czm_octDecode(vec2 encoded, out vec3 vector1, out vec3 vector2, out vec3 vector3)
  3032. {
  3033. float temp = encoded.x / 65536.0;
  3034. float x = floor(temp);
  3035. float encodedFloat1 = (temp - x) * 65536.0;
  3036. temp = encoded.y / 65536.0;
  3037. float y = floor(temp);
  3038. float encodedFloat2 = (temp - y) * 65536.0;
  3039. vector1 = czm_octDecode(encodedFloat1);
  3040. vector2 = czm_octDecode(encodedFloat2);
  3041. vector3 = czm_octDecode(vec2(x, y));
  3042. }
  3043. `;var zo=`/**
  3044. * Packs a depth value into a vec3 that can be represented by unsigned bytes.
  3045. *
  3046. * @name czm_packDepth
  3047. * @glslFunction
  3048. *
  3049. * @param {float} depth The floating-point depth.
  3050. * @returns {vec3} The packed depth.
  3051. */
  3052. vec4 czm_packDepth(float depth)
  3053. {
  3054. // See Aras Pranckevi\u010Dius' post Encoding Floats to RGBA
  3055. vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * depth;
  3056. enc = fract(enc);
  3057. enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);
  3058. return enc;
  3059. }
  3060. `;var bo=`/**
  3061. * Packs a float value into a vec3 that can be represented by unsigned bytes.
  3062. *
  3063. * @name czm_packValue
  3064. * @glslFunction
  3065. *
  3066. * @param {float} value The floating-point value.
  3067. * @returns {vec3} The packed value.
  3068. */
  3069. vec4 czm_packValue(float value)
  3070. {
  3071. float SHIFT_LEFT8 = 256.0;
  3072. float SHIFT_RIGHT8 = 1.0 / 256.0;
  3073. vec4 result;
  3074. result.a = 255.0;
  3075. float fPos = abs(value + 9000.0) * SHIFT_RIGHT8;
  3076. result.b = (fPos - floor(fPos)) * SHIFT_LEFT8;
  3077. fPos = floor(fPos) * SHIFT_RIGHT8;
  3078. result.g = (fPos - floor(fPos)) * SHIFT_LEFT8;
  3079. result.r = floor(fPos);
  3080. result /= 255.0;
  3081. return result;
  3082. }
  3083. `;var wo=`float czm_private_getLambertDiffuseOfMaterial(vec3 lightDirectionEC, czm_material material)
  3084. {
  3085. return czm_getLambertDiffuse(lightDirectionEC, material.normal);
  3086. }
  3087. float czm_private_getSpecularOfMaterial(vec3 lightDirectionEC, vec3 toEyeEC, czm_material material)
  3088. {
  3089. return czm_getSpecular(lightDirectionEC, toEyeEC, material.normal, material.shininess);
  3090. }
  3091. /**
  3092. * Computes a color using the Phong lighting model.
  3093. *
  3094. * @name czm_phong
  3095. * @glslFunction
  3096. *
  3097. * @param {vec3} toEye A normalized vector from the fragment to the eye in eye coordinates.
  3098. * @param {czm_material} material The fragment's material.
  3099. *
  3100. * @returns {vec4} The computed color.
  3101. *
  3102. * @example
  3103. * vec3 positionToEyeEC = // ...
  3104. * czm_material material = // ...
  3105. * vec3 lightDirectionEC = // ...
  3106. * gl_FragColor = czm_phong(normalize(positionToEyeEC), material, lightDirectionEC);
  3107. *
  3108. * @see czm_getMaterial
  3109. */
  3110. vec4 czm_phong(vec3 toEye, czm_material material, vec3 lightDirectionEC)
  3111. {
  3112. // Diffuse from directional light sources at eye (for top-down)
  3113. float diffuse = czm_private_getLambertDiffuseOfMaterial(vec3(0.0, 0.0, 1.0), material);
  3114. if (czm_sceneMode == czm_sceneMode3D) {
  3115. // (and horizon views in 3D)
  3116. diffuse += czm_private_getLambertDiffuseOfMaterial(vec3(0.0, 1.0, 0.0), material);
  3117. }
  3118. float specular = czm_private_getSpecularOfMaterial(lightDirectionEC, toEye, material);
  3119. // Temporary workaround for adding ambient.
  3120. vec3 materialDiffuse = material.diffuse * 0.5;
  3121. vec3 ambient = materialDiffuse;
  3122. vec3 color = ambient + material.emission;
  3123. color += materialDiffuse * diffuse * czm_lightColor;
  3124. color += material.specular * specular * czm_lightColor;
  3125. return vec4(color, material.alpha);
  3126. }
  3127. vec4 czm_private_phong(vec3 toEye, czm_material material, vec3 lightDirectionEC)
  3128. {
  3129. float diffuse = czm_private_getLambertDiffuseOfMaterial(lightDirectionEC, material);
  3130. float specular = czm_private_getSpecularOfMaterial(lightDirectionEC, toEye, material);
  3131. vec3 ambient = vec3(0.0);
  3132. vec3 color = ambient + material.emission;
  3133. color += material.diffuse * diffuse * czm_lightColor;
  3134. color += material.specular * specular * czm_lightColor;
  3135. return vec4(color, material.alpha);
  3136. }
  3137. `;var Lo=`/**
  3138. * Computes distance from a point to a plane.
  3139. *
  3140. * @name czm_planeDistance
  3141. * @glslFunction
  3142. *
  3143. * param {vec4} plane A Plane in Hessian Normal Form. See Plane.js
  3144. * param {vec3} point A point in the same space as the plane.
  3145. * returns {float} The distance from the point to the plane.
  3146. */
  3147. float czm_planeDistance(vec4 plane, vec3 point) {
  3148. return (dot(plane.xyz, point) + plane.w);
  3149. }
  3150. /**
  3151. * Computes distance from a point to a plane.
  3152. *
  3153. * @name czm_planeDistance
  3154. * @glslFunction
  3155. *
  3156. * param {vec3} planeNormal Normal for a plane in Hessian Normal Form. See Plane.js
  3157. * param {float} planeDistance Distance for a plane in Hessian Normal form. See Plane.js
  3158. * param {vec3} point A point in the same space as the plane.
  3159. * returns {float} The distance from the point to the plane.
  3160. */
  3161. float czm_planeDistance(vec3 planeNormal, float planeDistance, vec3 point) {
  3162. return (dot(planeNormal, point) + planeDistance);
  3163. }
  3164. `;var So=`/**
  3165. * Computes the point along a ray at the given time. <code>time</code> can be positive, negative, or zero.
  3166. *
  3167. * @name czm_pointAlongRay
  3168. * @glslFunction
  3169. *
  3170. * @param {czm_ray} ray The ray to compute the point along.
  3171. * @param {float} time The time along the ray.
  3172. *
  3173. * @returns {vec3} The point along the ray at the given time.
  3174. *
  3175. * @example
  3176. * czm_ray ray = czm_ray(vec3(0.0), vec3(1.0, 0.0, 0.0)); // origin, direction
  3177. * vec3 v = czm_pointAlongRay(ray, 2.0); // (2.0, 0.0, 0.0)
  3178. */
  3179. vec3 czm_pointAlongRay(czm_ray ray, float time)
  3180. {
  3181. return ray.origin + (time * ray.direction);
  3182. }
  3183. `;var Eo=`/**
  3184. * DOC_TBA
  3185. *
  3186. * @name czm_rayEllipsoidIntersectionInterval
  3187. * @glslFunction
  3188. */
  3189. czm_raySegment czm_rayEllipsoidIntersectionInterval(czm_ray ray, vec3 ellipsoid_center, vec3 ellipsoid_inverseRadii)
  3190. {
  3191. // ray and ellipsoid center in eye coordinates. radii in model coordinates.
  3192. vec3 q = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ray.origin, 1.0)).xyz;
  3193. vec3 w = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ray.direction, 0.0)).xyz;
  3194. q = q - ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ellipsoid_center, 1.0)).xyz;
  3195. float q2 = dot(q, q);
  3196. float qw = dot(q, w);
  3197. if (q2 > 1.0) // Outside ellipsoid.
  3198. {
  3199. if (qw >= 0.0) // Looking outward or tangent (0 intersections).
  3200. {
  3201. return czm_emptyRaySegment;
  3202. }
  3203. else // qw < 0.0.
  3204. {
  3205. float qw2 = qw * qw;
  3206. float difference = q2 - 1.0; // Positively valued.
  3207. float w2 = dot(w, w);
  3208. float product = w2 * difference;
  3209. if (qw2 < product) // Imaginary roots (0 intersections).
  3210. {
  3211. return czm_emptyRaySegment;
  3212. }
  3213. else if (qw2 > product) // Distinct roots (2 intersections).
  3214. {
  3215. float discriminant = qw * qw - product;
  3216. float temp = -qw + sqrt(discriminant); // Avoid cancellation.
  3217. float root0 = temp / w2;
  3218. float root1 = difference / temp;
  3219. if (root0 < root1)
  3220. {
  3221. czm_raySegment i = czm_raySegment(root0, root1);
  3222. return i;
  3223. }
  3224. else
  3225. {
  3226. czm_raySegment i = czm_raySegment(root1, root0);
  3227. return i;
  3228. }
  3229. }
  3230. else // qw2 == product. Repeated roots (2 intersections).
  3231. {
  3232. float root = sqrt(difference / w2);
  3233. czm_raySegment i = czm_raySegment(root, root);
  3234. return i;
  3235. }
  3236. }
  3237. }
  3238. else if (q2 < 1.0) // Inside ellipsoid (2 intersections).
  3239. {
  3240. float difference = q2 - 1.0; // Negatively valued.
  3241. float w2 = dot(w, w);
  3242. float product = w2 * difference; // Negatively valued.
  3243. float discriminant = qw * qw - product;
  3244. float temp = -qw + sqrt(discriminant); // Positively valued.
  3245. czm_raySegment i = czm_raySegment(0.0, temp / w2);
  3246. return i;
  3247. }
  3248. else // q2 == 1.0. On ellipsoid.
  3249. {
  3250. if (qw < 0.0) // Looking inward.
  3251. {
  3252. float w2 = dot(w, w);
  3253. czm_raySegment i = czm_raySegment(0.0, -qw / w2);
  3254. return i;
  3255. }
  3256. else // qw >= 0.0. Looking outward or tangent.
  3257. {
  3258. return czm_emptyRaySegment;
  3259. }
  3260. }
  3261. }
  3262. `;var Ao=`float czm_readDepth(sampler2D depthTexture, vec2 texCoords)
  3263. {
  3264. return czm_reverseLogDepth(texture2D(depthTexture, texCoords).r);
  3265. }
  3266. `;var Do=`/**
  3267. * Reads a value previously transformed with {@link czm_writeNonPerspective}
  3268. * by dividing it by \`w\`, the value used in the perspective divide.
  3269. * This function is intended to be called in a fragment shader to access a
  3270. * \`varying\` that should not be subject to perspective interpolation.
  3271. * For example, screen-space texture coordinates. The value should have been
  3272. * previously written in the vertex shader with a call to
  3273. * {@link czm_writeNonPerspective}.
  3274. *
  3275. * @name czm_readNonPerspective
  3276. * @glslFunction
  3277. *
  3278. * @param {float|vec2|vec3|vec4} value The non-perspective value to be read.
  3279. * @param {float} oneOverW One over the perspective divide value, \`w\`. Usually this is simply \`gl_FragCoord.w\`.
  3280. * @returns {float|vec2|vec3|vec4} The usable value.
  3281. */
  3282. float czm_readNonPerspective(float value, float oneOverW) {
  3283. return value * oneOverW;
  3284. }
  3285. vec2 czm_readNonPerspective(vec2 value, float oneOverW) {
  3286. return value * oneOverW;
  3287. }
  3288. vec3 czm_readNonPerspective(vec3 value, float oneOverW) {
  3289. return value * oneOverW;
  3290. }
  3291. vec4 czm_readNonPerspective(vec4 value, float oneOverW) {
  3292. return value * oneOverW;
  3293. }
  3294. `;var Oo=`float czm_reverseLogDepth(float logZ)
  3295. {
  3296. #ifdef LOG_DEPTH
  3297. float near = czm_currentFrustum.x;
  3298. float far = czm_currentFrustum.y;
  3299. float log2Depth = logZ * czm_log2FarDepthFromNearPlusOne;
  3300. float depthFromNear = pow(2.0, log2Depth) - 1.0;
  3301. return far * (1.0 - near / (depthFromNear + near)) / (far - near);
  3302. #endif
  3303. return logZ;
  3304. }
  3305. `;var Io=`const vec4 RGBA4_2_FLOAT_FACTORS = vec4(
  3306. 15.0 / (16.0),
  3307. 15.0 / (16.0 * 16.0),
  3308. 15.0 / (16.0 * 16.0 * 16.0),
  3309. 15.0 / (16.0 * 16.0 * 16.0 * 16.0)
  3310. );
  3311. float czm_RGBA4ToFloat(vec4 rgba) {
  3312. return dot(rgba, RGBA4_2_FLOAT_FACTORS);
  3313. }`;var Ro=`/**
  3314. * Converts an RGB color to HSB (hue, saturation, brightness)
  3315. * HSB <-> RGB conversion with minimal branching:
  3316. *
  3317. * @name czm_RGBToHSB
  3318. * @glslFunction
  3319. *
  3320. * @param {vec3} rgb The color in RGB.
  3321. *
  3322. * @returns {vec3} The color in HSB.
  3323. *
  3324. * @example
  3325. * vec3 hsb = czm_RGBToHSB(rgb);
  3326. * hsb.z *= 0.1;
  3327. * rgb = czm_HSBToRGB(hsb);
  3328. */
  3329. const vec4 K_RGB2HSB = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
  3330. vec3 czm_RGBToHSB(vec3 rgb)
  3331. {
  3332. vec4 p = mix(vec4(rgb.bg, K_RGB2HSB.wz), vec4(rgb.gb, K_RGB2HSB.xy), step(rgb.b, rgb.g));
  3333. vec4 q = mix(vec4(p.xyw, rgb.r), vec4(rgb.r, p.yzx), step(p.x, rgb.r));
  3334. float d = q.x - min(q.w, q.y);
  3335. return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + czm_epsilon7)), d / (q.x + czm_epsilon7), q.x);
  3336. }
  3337. `;var Mo=`/**
  3338. * Converts an RGB color to HSL (hue, saturation, lightness)
  3339. * HSL <-> RGB conversion:
  3340. *
  3341. * @name czm_RGBToHSL
  3342. * @glslFunction
  3343. *
  3344. * @param {vec3} rgb The color in RGB.
  3345. *
  3346. * @returns {vec3} The color in HSL.
  3347. *
  3348. * @example
  3349. * vec3 hsl = czm_RGBToHSL(rgb);
  3350. * hsl.z *= 0.1;
  3351. * rgb = czm_HSLToRGB(hsl);
  3352. */
  3353. vec3 RGBtoHCV(vec3 rgb)
  3354. {
  3355. // Based on work by Sam Hocevar and Emil Persson
  3356. vec4 p = (rgb.g < rgb.b) ? vec4(rgb.bg, -1.0, 2.0 / 3.0) : vec4(rgb.gb, 0.0, -1.0 / 3.0);
  3357. vec4 q = (rgb.r < p.x) ? vec4(p.xyw, rgb.r) : vec4(rgb.r, p.yzx);
  3358. float c = q.x - min(q.w, q.y);
  3359. float h = abs((q.w - q.y) / (6.0 * c + czm_epsilon7) + q.z);
  3360. return vec3(h, c, q.x);
  3361. }
  3362. vec3 czm_RGBToHSL(vec3 rgb)
  3363. {
  3364. vec3 hcv = RGBtoHCV(rgb);
  3365. float l = hcv.z - hcv.y * 0.5;
  3366. float s = hcv.y / (1.0 - abs(l * 2.0 - 1.0) + czm_epsilon7);
  3367. return vec3(hcv.x, s, l);
  3368. }
  3369. `;var Po=`/**
  3370. * Converts an RGB color to CIE Yxy.
  3371. * <p>The conversion is described in
  3372. * </p>
  3373. *
  3374. * @name czm_RGBToXYZ
  3375. * @glslFunction
  3376. *
  3377. * @param {vec3} rgb The color in RGB.
  3378. *
  3379. * @returns {vec3} The color in CIE Yxy.
  3380. *
  3381. * @example
  3382. * vec3 xyz = czm_RGBToXYZ(rgb);
  3383. * xyz.x = max(xyz.x - luminanceThreshold, 0.0);
  3384. * rgb = czm_XYZToRGB(xyz);
  3385. */
  3386. vec3 czm_RGBToXYZ(vec3 rgb)
  3387. {
  3388. const mat3 RGB2XYZ = mat3(0.4124, 0.2126, 0.0193,
  3389. 0.3576, 0.7152, 0.1192,
  3390. 0.1805, 0.0722, 0.9505);
  3391. vec3 xyz = RGB2XYZ * rgb;
  3392. vec3 Yxy;
  3393. Yxy.r = xyz.g;
  3394. float temp = dot(vec3(1.0), xyz);
  3395. Yxy.gb = xyz.rg / temp;
  3396. return Yxy;
  3397. }
  3398. `;var Vo=`void czm_RollerShutter(vec2 coord, vec4 region)
  3399. {
  3400. vec2 f = step(region.xw, coord);
  3401. vec2 s = step(coord, region.zy);
  3402. if (f.x * f.y * s.x * s.y < 1.0)
  3403. {
  3404. discard;
  3405. };
  3406. }
  3407. `;var Fo=`void czm_s3mBatchOperation(vec4 operationType, vec4 color, vec4 selectedColor, inout vec4 vertexColor, inout vec4 vertexPos, inout vec4 vIsFiltByID, vec3 translation)
  3408. {
  3409. float right_2 = operationType.x * 0.5;
  3410. float right_4 = right_2 * 0.5;
  3411. float right_8 = right_4 * 0.5;
  3412. float right_16 = right_8 * 0.5;
  3413. float isSetColor = fract(right_2);
  3414. if(isSetColor > 0.1)
  3415. {
  3416. vertexColor *= color;
  3417. }
  3418. float isPicked = fract(floor(right_2)* 0.5);
  3419. if(isPicked > 0.1)
  3420. {
  3421. vertexColor *= selectedColor;
  3422. }
  3423. float isHide = fract(floor(right_4)* 0.5);
  3424. if(isHide > 0.1)
  3425. {
  3426. vertexColor.a = 0.0;
  3427. }
  3428. float isOffset = fract(floor(right_8)* 0.5);
  3429. if(isOffset > 0.1)
  3430. {
  3431. vertexPos.xyz += translation;
  3432. }
  3433. float isClip = fract(floor(right_16) * 0.5);
  3434. if(isClip > 0.1)
  3435. {
  3436. vIsFiltByID.x = 1.0;
  3437. }
  3438. }
  3439. void czm_s3mBatchOperation(vec4 operationType, vec4 color, inout vec4 vertexColor, inout vec4 vertexPos, inout vec4 vIsFiltByID, vec3 translation, inout float fSelected)
  3440. {
  3441. operationType.x += 0.001;
  3442. float right_2 = operationType.x * 0.5;
  3443. float right_4 = right_2 * 0.5;
  3444. float right_8 = right_4 * 0.5;
  3445. float right_16 = right_8 * 0.5;
  3446. float isSetColor = fract(right_2);
  3447. if(isSetColor > 0.1)
  3448. {
  3449. vertexColor *= color;
  3450. }
  3451. float isPicked = fract(floor(right_2)* 0.5);
  3452. if(isPicked > 0.1)
  3453. {
  3454. fSelected = 1.0;
  3455. }
  3456. float isHide = fract(floor(right_4)* 0.5);
  3457. if(isHide > 0.1)
  3458. {
  3459. vertexColor.a = 0.0;
  3460. }
  3461. float isOffset = fract(floor(right_8)* 0.5);
  3462. if(isOffset > 0.1)
  3463. {
  3464. vertexPos.xyz += translation;
  3465. }
  3466. float isClip = fract(floor(right_16) * 0.5);
  3467. if(isClip > 0.1)
  3468. {
  3469. vIsFiltByID.x = 1.0;
  3470. }
  3471. }
  3472. void czm_s3mBatchOperation(vec4 operationType, vec4 color, vec4 selectedColor, inout vec4 vertexColor, inout vec4 vertexPos, inout vec4 vIsFiltByID, vec3 translation, inout float fSelected)
  3473. {
  3474. operationType.x += 0.001;
  3475. float right_2 = operationType.x * 0.5;
  3476. float right_4 = right_2 * 0.5;
  3477. float right_8 = right_4 * 0.5;
  3478. float right_16 = right_8 * 0.5;
  3479. float isSetColor = fract(right_2);
  3480. if(isSetColor > 0.1)
  3481. {
  3482. #ifdef REPLACE_COLOR_TYPE
  3483. vertexColor.rgb = color.rgb;
  3484. #else
  3485. vertexColor.rgb *= color.rgb;
  3486. #endif
  3487. vertexColor.a *= color.a;
  3488. }
  3489. float isPicked = fract(floor(right_2)* 0.5);
  3490. if(isPicked > 0.1)
  3491. {
  3492. fSelected = 1.0;
  3493. #ifdef REPLACE_SELECT_TYPE
  3494. vertexColor = selectedColor;
  3495. #else
  3496. vertexColor *= selectedColor;
  3497. #endif
  3498. }
  3499. float isHide = fract(floor(right_4)* 0.5);
  3500. if(isHide > 0.1)
  3501. {
  3502. vertexColor.a = 0.0;
  3503. }
  3504. float isOffset = fract(floor(right_8)* 0.5);
  3505. if(isOffset > 0.1)
  3506. {
  3507. vertexPos.xyz += translation;
  3508. }
  3509. float isClip = fract(floor(right_16) * 0.5);
  3510. if(isClip > 0.1)
  3511. {
  3512. vIsFiltByID.x = 1.0;
  3513. }
  3514. }
  3515. void czm_s3mBatchOperation(vec4 operationType, vec4 color, vec4 selectedColor, inout vec4 vertexColor)
  3516. {
  3517. operationType.x += 0.001;
  3518. float right_2 = operationType.x * 0.5;
  3519. float right_4 = right_2 * 0.5;
  3520. float right_8 = right_4 * 0.5;
  3521. float right_16 = right_8 * 0.5;
  3522. float isSetColor = fract(right_2);
  3523. if(isSetColor > 0.1)
  3524. {
  3525. #ifdef REPLACE_COLOR_TYPE
  3526. vertexColor.rgb = color.rgb;
  3527. #else
  3528. vertexColor.rgb *= color.rgb;
  3529. #endif
  3530. vertexColor.a *= color.a;
  3531. }
  3532. float isPicked = fract(floor(right_2)* 0.5);
  3533. if(isPicked > 0.1)
  3534. {
  3535. vertexColor *= selectedColor;
  3536. }
  3537. float isHide = fract(floor(right_4)* 0.5);
  3538. if(isHide > 0.1)
  3539. {
  3540. vertexColor.a = 0.0;
  3541. }
  3542. }
  3543. void czm_s3mBatchOperation(vec4 operationType, vec4 color, vec4 selectedColor, inout vec4 vertexColor, inout float fSelected)
  3544. {
  3545. operationType.x += 0.001;
  3546. float right_2 = operationType.x * 0.5;
  3547. float right_4 = right_2 * 0.5;
  3548. float right_8 = right_4 * 0.5;
  3549. float right_16 = right_8 * 0.5;
  3550. float isSetColor = fract(right_2);
  3551. if(isSetColor > 0.1)
  3552. {
  3553. fSelected = 1.0;
  3554. vertexColor = color;
  3555. }
  3556. float isPicked = fract(floor(right_2)* 0.5);
  3557. if(isPicked > 0.1)
  3558. {
  3559. fSelected = 1.0;
  3560. vertexColor = selectedColor;
  3561. }
  3562. float isHide = fract(floor(right_4)* 0.5);
  3563. if(isHide > 0.1)
  3564. {
  3565. vertexColor.a = 0.0;
  3566. }
  3567. }
  3568. void czm_s3mBatchOperation(vec4 operationType, vec4 color, vec4 selectedColor, inout vec4 vertexColor, inout vec4 vertexPos, inout vec4 vIsFiltByID, vec3 translation, inout vec2 fSelected)
  3569. {
  3570. operationType.x += 0.001;
  3571. float right_2 = operationType.x * 0.5;
  3572. float right_4 = right_2 * 0.5;
  3573. float right_8 = right_4 * 0.5;
  3574. float right_16 = right_8 * 0.5;
  3575. float isSetColor = fract(right_2);
  3576. if(isSetColor > 0.1)
  3577. {
  3578. fSelected.y = 1.0;
  3579. color.a *= vertexColor.a;
  3580. vertexColor = color;
  3581. }
  3582. float isPicked = fract(floor(right_2)* 0.5);
  3583. if(isPicked > 0.1)
  3584. {
  3585. fSelected.x = 1.0;
  3586. #ifdef REPLACE_SELECT_TYPE
  3587. vertexColor = selectedColor;
  3588. #else
  3589. vertexColor *= selectedColor;
  3590. #endif
  3591. }
  3592. float isHide = fract(floor(right_4)* 0.5);
  3593. if(isHide > 0.1)
  3594. {
  3595. vertexColor.a = 0.0;
  3596. }
  3597. float isOffset = fract(floor(right_8)* 0.5);
  3598. if(isOffset > 0.1)
  3599. {
  3600. vertexPos.xyz += translation;
  3601. }
  3602. float isClip = fract(floor(right_16) * 0.5);
  3603. if(isClip > 0.1)
  3604. {
  3605. vIsFiltByID.x = 1.0;
  3606. }
  3607. }`;var Bo=` uniform float u_metallicFactor;
  3608. uniform float u_roughnessFactor;
  3609. uniform vec4 u_emissiveFactor;
  3610. uniform vec4 u_baseColorFactor;
  3611. uniform float u_alphaCutoff;
  3612. uniform sampler2D u_baseColorTexture;
  3613. uniform sampler2D u_metallicRoughnessTexture;
  3614. uniform sampler2D u_normalTexture;
  3615. uniform sampler2D u_occlusionTexture;
  3616. uniform sampler2D u_emissiveTexture;
  3617. uniform vec4 u_baseColorUVOffsetAndTiling;
  3618. uniform vec4 u_emissiveUVOffsetAndTiling;
  3619. uniform float uSunLightON;
  3620. #if DIR_LIGHTS > 0
  3621. uniform vec3 uDirectionalLightDirectionEC[ DIR_LIGHTS ];
  3622. uniform vec3 uDirectionalLightColor[ DIR_LIGHTS ];
  3623. #endif
  3624. #if POINT_LIGHTS > 0
  3625. uniform vec3 uPointLightPositionEC[ POINT_LIGHTS ];
  3626. uniform vec3 uPointLightColor[ POINT_LIGHTS ];
  3627. uniform vec2 uPointLightDistanceAndDecay[ POINT_LIGHTS ];
  3628. #endif
  3629. #if SPOT_LIGHTS > 0
  3630. uniform vec3 uSpotLightColor[ SPOT_LIGHTS ];
  3631. uniform vec3 uSpotLightPositionEC[ SPOT_LIGHTS ];
  3632. uniform vec3 uSpotLightDirectionEC[ SPOT_LIGHTS ];
  3633. uniform vec3 uSpotLightDistanceDecayCos[ SPOT_LIGHTS ];
  3634. uniform vec3 uSpotLightExponent[ SPOT_LIGHTS ];
  3635. #endif
  3636. const float M_PI = 3.141592653589793;
  3637. vec3 lambertianDiffuse(vec3 diffuseColor)
  3638. {
  3639. return diffuseColor / M_PI;
  3640. }
  3641. vec3 fresnelSchlick2(vec3 f0, vec3 f90, float VdotH)
  3642. {
  3643. return f0 + (f90 - f0) * pow(clamp(1.0 - VdotH, 0.0, 1.0), 5.0);
  3644. }
  3645. vec3 fresnelSchlick(float metalness, float VdotH)
  3646. {
  3647. return metalness + (vec3(1.0) - metalness) * pow(1.0 - VdotH, 5.0);
  3648. }
  3649. vec3 F_Schlick(float ndv, vec3 spec)
  3650. {
  3651. return spec + (vec3(1.0) - spec) * pow(1.0 - ndv, 5.0);
  3652. }
  3653. float D_Phong(float g, float ndh)
  3654. {
  3655. float a = pow(8192.0, g);
  3656. return (a + 2.0) / 8.0 * pow(ndh, a);
  3657. }
  3658. float smithVisibilityG1(float NdotV, float roughness)
  3659. {
  3660. float k = (roughness + 1.0) * (roughness + 1.0) / 8.0;
  3661. return NdotV / (NdotV * (1.0 - k) + k);
  3662. }
  3663. float smithVisibilityGGX(float roughness, float NdotL, float NdotV)
  3664. {
  3665. return smithVisibilityG1(NdotL, roughness) * smithVisibilityG1(NdotV, roughness);
  3666. }
  3667. float GGX(float roughness, float NdotH)
  3668. {
  3669. float roughnessSquared = roughness * roughness;
  3670. float f = (NdotH * roughnessSquared - NdotH) * NdotH + 1.0;
  3671. return roughnessSquared / (M_PI * f * f);
  3672. }
  3673. void getLightColor(vec3 lightDir, vec3 viewDir, vec3 normal, vec3 lightColor, vec3 fresnelTerm, float roughness, out vec3 diffuseTerm, out vec3 specularTerm)
  3674. {
  3675. vec3 h = normalize(viewDir + lightDir);
  3676. float NdotL = clamp(dot(normal, lightDir), 0.001, 1.0);
  3677. float NdotH = clamp(dot(normal, h), 0.0, 1.0);
  3678. vec3 li = lightColor * NdotL;
  3679. diffuseTerm = li;
  3680. specularTerm = li * fresnelTerm * D_Phong(1.0 - roughness, NdotH);
  3681. }
  3682. vec3 SRGBtoLINEAR3(vec3 srgbIn)
  3683. {
  3684. return pow(srgbIn, vec3(2.2));
  3685. }
  3686. vec4 SRGBtoLINEAR4(vec4 srgbIn)
  3687. {
  3688. vec3 linearOut = pow(srgbIn.rgb, vec3(2.2));
  3689. return vec4(linearOut, srgbIn.a);
  3690. }
  3691. vec3 LINEARtoSRGB(vec3 linearIn)
  3692. {
  3693. #ifndef HDR
  3694. return pow(linearIn, vec3(1.0/2.2));
  3695. #else
  3696. return linearIn;
  3697. #endif
  3698. }
  3699. float calcLightAttenuation(float lightDistance, float cutoffDistance, float decayExponent)
  3700. {
  3701. return pow(clamp(1.0 - lightDistance / cutoffDistance, 0.0, 1.0), decayExponent);
  3702. }
  3703. vec4 czm_S3MPBR(vec3 normalEC, vec3 positionEC, vec2 texCoord, vec4 vertexColor)
  3704. {
  3705. vec3 ng = normalize(normalEC);
  3706. vec3 positionWC = (czm_inverseView * vec4(positionEC, 1.0)).xyz;
  3707. #ifdef HAS_NORMAL_TEXTURE
  3708. vec3 pos_dx = dFdx(positionEC);
  3709. vec3 pos_dy = dFdy(positionEC);
  3710. vec3 tex_dx = dFdx(vec3(texCoord, 0.0));
  3711. vec3 tex_dy = dFdy(vec3(texCoord, 0.0));
  3712. vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);
  3713. t = normalize(t - ng * dot(ng, t));
  3714. vec3 b = normalize(cross(ng, t));
  3715. mat3 tbn = mat3(t, b, ng);
  3716. vec3 n = texture2D(u_normalTexture, texCoord).rgb;
  3717. n = normalize(tbn * (2.0 * n - 1.0));
  3718. #else
  3719. vec3 n = ng;
  3720. #endif
  3721. vec3 v = -normalize(positionEC);
  3722. #ifdef DOUBLE_SIDED
  3723. if (dot(n, v) < 0.0) {
  3724. n = -n;
  3725. }
  3726. #endif
  3727. // Add base color to fragment shader
  3728. #ifdef HAS_BASECOLOR_TEXTURE
  3729. vec2 baseColorTexCoord = texCoord;
  3730. baseColorTexCoord = baseColorTexCoord * u_baseColorUVOffsetAndTiling.zw + u_baseColorUVOffsetAndTiling.xy;
  3731. vec4 baseColorWithAlpha = SRGBtoLINEAR4(texture2D(u_baseColorTexture, baseColorTexCoord));
  3732. baseColorWithAlpha *= u_baseColorFactor;
  3733. #else
  3734. vec4 baseColorWithAlpha = u_baseColorFactor;
  3735. #endif
  3736. baseColorWithAlpha *= vertexColor;
  3737. vec3 baseColor = baseColorWithAlpha.rgb;
  3738. #ifdef HAS_METALLICROUGHNESS_TEXTURE
  3739. vec3 metallicRoughness = texture2D(u_metallicRoughnessTexture, texCoord).rgb;
  3740. float metalness = clamp(metallicRoughness.b, 0.0, 1.0);
  3741. float roughness = clamp(metallicRoughness.g, 0.04, 1.0);
  3742. metalness *= u_metallicFactor;
  3743. roughness *= u_roughnessFactor;
  3744. #else
  3745. float metalness = clamp(u_metallicFactor, 0.0, 1.0);
  3746. float roughness = clamp(u_roughnessFactor, 0.04, 1.0);
  3747. #endif
  3748. vec3 f0 = vec3(0.04);
  3749. vec3 diffuseColor = baseColor * (1.0 - metalness) * (1.0 - f0);
  3750. vec3 specularColor = mix(f0, baseColor, metalness);
  3751. float NdotV = abs(dot(n, v)) + 0.001;
  3752. vec3 diffuseTerm = vec3(0.0);
  3753. vec3 specularTerm = vec3(0.0);
  3754. vec3 fresnelTerm = F_Schlick(NdotV, specularColor);
  3755. vec3 color = vec3(0.0);
  3756. // \u9ED8\u8BA4\u52A0\u4E00\u4E2A\u5E73\u884C\u5149\u4F5C\u4E3A\u592A\u9633\u5149
  3757. vec3 lightDiffuseTerm = vec3(0.0);
  3758. vec3 lightSpecularTerm = vec3(0.0);
  3759. getLightColor(czm_sunDirectionEC, v, n, vec3(0.8), fresnelTerm, roughness, lightDiffuseTerm, lightSpecularTerm);
  3760. diffuseTerm +=lightDiffuseTerm * uSunLightON;
  3761. specularTerm += lightSpecularTerm * uSunLightON;
  3762. #if DIR_LIGHTS > 0
  3763. for (int i = 0; i < DIR_LIGHTS; i++) {
  3764. getLightColor(uDirectionalLightDirectionEC[i], v, n, uDirectionalLightColor[i], fresnelTerm, roughness, lightDiffuseTerm, lightSpecularTerm);
  3765. diffuseTerm +=lightDiffuseTerm;
  3766. specularTerm += lightSpecularTerm;
  3767. }
  3768. #endif
  3769. #if POINT_LIGHTS > 0
  3770. for (int i = 0; i < POINT_LIGHTS; i++) {
  3771. vec3 lVector = uPointLightPositionEC[i] - v_positionEC;
  3772. float lightDistance = length(lVector);
  3773. float lightAttenuation = calcLightAttenuation(lightDistance, uPointLightDistanceAndDecay[i].x, uPointLightDistanceAndDecay[i].y);
  3774. if(lightAttenuation < 0.001) {
  3775. continue;
  3776. }
  3777. vec3 pointLightColor = uPointLightColor[i] * lightAttenuation;
  3778. vec3 lightDiffuseTerm = vec3(0.0);
  3779. vec3 lightSpecularTerm = vec3(0.0);
  3780. getLightColor(normalize(lVector), v, n, pointLightColor, fresnelTerm, roughness, lightDiffuseTerm, lightSpecularTerm);
  3781. diffuseTerm +=lightDiffuseTerm;
  3782. specularTerm += lightSpecularTerm;
  3783. }
  3784. #endif
  3785. #if SPOT_LIGHTS > 0
  3786. for (int i = 0; i < SPOT_LIGHTS; i++) {
  3787. vec3 lVector = uSpotLightPositionEC[i] - v_positionEC;
  3788. float lightDistance = length(lVector);
  3789. float lightAttenuation = calcLightAttenuation(lightDistance, uSpotLightDistanceDecayCos[i].x, uSpotLightDistanceDecayCos[i].y);
  3790. if(lightAttenuation < 0.001) {
  3791. continue;
  3792. }
  3793. float spotEffect = dot(uSpotLightDirectionEC[i], normalize(lVector));
  3794. if(spotEffect > uSpotLightDistanceDecayCos[i].z) {
  3795. vec3 spotLightColor = uSpotLightColor[i] * lightAttenuation * spotEffect;
  3796. vec3 lightDiffuseTerm = vec3(0.0);
  3797. vec3 lightSpecularTerm = vec3(0.0);
  3798. getLightColor(normalize(lVector), v, n, spotLightColor, fresnelTerm, roughness, lightDiffuseTerm, lightSpecularTerm);
  3799. diffuseTerm +=lightDiffuseTerm;
  3800. specularTerm += lightSpecularTerm;
  3801. }
  3802. }
  3803. #endif
  3804. color = baseColor;
  3805. color *= max(diffuseTerm, vec3(0.0));
  3806. color += max(specularTerm, vec3(0.0));
  3807. // \u8BA1\u7B97\u73AF\u5883\u5149
  3808. #ifdef USE_IBL_LIGHTING
  3809. vec3 r = normalize(czm_inverseViewRotation * normalize(reflect(v, n)));
  3810. // Figure out if the reflection vector hits the ellipsoid
  3811. float vertexRadius = length(positionWC);
  3812. float horizonDotNadir = 1.0 - min(1.0, 6378137.0 / vertexRadius);
  3813. float reflectionDotNadir = dot(r, normalize(positionWC));
  3814. // Flipping the X vector is a cheap way to get the inverse of czm_temeToPseudoFixed, since that's a rotation about Z.
  3815. r.x = -r.x;
  3816. r = -normalize(czm_temeToPseudoFixed * r);
  3817. r.x = -r.x;
  3818. float inverseRoughness = 1.04 - roughness;
  3819. inverseRoughness *= inverseRoughness;
  3820. vec3 sceneSkyBox = textureCube(czm_environmentMap, r).rgb * inverseRoughness;
  3821. float atmosphereHeight = 0.05;
  3822. float blendRegionSize = 0.1 * ((1.0 - inverseRoughness) * 8.0 + 1.1 - horizonDotNadir);
  3823. float blendRegionOffset = roughness * -1.0;
  3824. float farAboveHorizon = clamp(horizonDotNadir - blendRegionSize * 0.5 + blendRegionOffset, 1.0e-10 - blendRegionSize, 0.99999);
  3825. float aroundHorizon = clamp(horizonDotNadir + blendRegionSize * 0.5, 1.0e-10 - blendRegionSize, 0.99999);
  3826. float farBelowHorizon = clamp(horizonDotNadir + blendRegionSize * 1.5, 1.0e-10 - blendRegionSize, 0.99999);
  3827. float smoothstepHeight = smoothstep(0.0, atmosphereHeight, horizonDotNadir);
  3828. vec3 belowHorizonColor = mix(vec3(0.1, 0.15, 0.25), vec3(0.4, 0.7, 0.9), smoothstepHeight);
  3829. vec3 nadirColor = belowHorizonColor * 0.5;
  3830. vec3 aboveHorizonColor = mix(vec3(0.9, 1.0, 1.2), belowHorizonColor, roughness * 0.5);
  3831. vec3 blueSkyColor = mix(vec3(0.18, 0.26, 0.48), aboveHorizonColor, reflectionDotNadir * inverseRoughness * 0.5 + 0.75);
  3832. vec3 zenithColor = mix(blueSkyColor, sceneSkyBox, smoothstepHeight);
  3833. vec3 blueSkyDiffuseColor = vec3(0.7, 0.85, 0.9);
  3834. float diffuseIrradianceFromEarth = (1.0 - horizonDotNadir) * (reflectionDotNadir * 0.25 + 0.75) * smoothstepHeight;
  3835. float diffuseIrradianceFromSky = (1.0 - smoothstepHeight) * (1.0 - (reflectionDotNadir * 0.25 + 0.25));
  3836. vec3 diffuseIrradiance = blueSkyDiffuseColor * clamp(diffuseIrradianceFromEarth + diffuseIrradianceFromSky, 0.0, 1.0);
  3837. float notDistantRough = (1.0 - horizonDotNadir * roughness * 0.8);
  3838. vec3 specularIrradiance = mix(zenithColor, aboveHorizonColor, smoothstep(farAboveHorizon, aroundHorizon, reflectionDotNadir) * notDistantRough);
  3839. specularIrradiance = mix(specularIrradiance, belowHorizonColor, smoothstep(aroundHorizon, farBelowHorizon, reflectionDotNadir) * inverseRoughness);
  3840. specularIrradiance = mix(specularIrradiance, nadirColor, smoothstep(farBelowHorizon, 1.0, reflectionDotNadir) * inverseRoughness);
  3841. vec2 iblFactor = vec2(1.0);
  3842. float luminanceAtZenith = 0.5;
  3843. #ifdef USE_SUN_LUMINANCE
  3844. // Angle between sun and zenith
  3845. float LdotZenith = clamp(dot(normalize(czm_inverseViewRotation * czm_sunDirectionEC), normalize(positionWC * -1.0)), 0.001, 1.0);
  3846. float S = acos(LdotZenith);
  3847. // Angle between zenith and current pixel
  3848. float NdotZenith = clamp(dot(normalize(czm_inverseViewRotation * n), normalize(positionWC * -1.0)), 0.001, 1.0);
  3849. // Angle between sun and current pixel
  3850. float sunNdotL = clamp(dot(n, czm_sunDirectionEC), 0.001, 1.0);
  3851. float gamma = acos(sunNdotL);
  3852. float numerator = ((0.91 + 10.0 * exp(-3.0 * gamma) + 0.45 * pow(sunNdotL, 2.0)) * (1.0 - exp(-0.32 / NdotZenith)));
  3853. float denominator = (0.91 + 10.0 * exp(-3.0 * S) + 0.45 * pow(LdotZenith,2.0)) * (1.0 - exp(-0.32));
  3854. float luminance = luminanceAtZenith * (numerator / denominator);
  3855. #endif
  3856. vec2 brdfLut = texture2D(czm_brdfLut, vec2(NdotV, 1.0 - roughness)).rg;
  3857. vec3 IBLColor = (diffuseIrradiance * diffuseColor * iblFactor.x) + (specularIrradiance * SRGBtoLINEAR3(specularColor * brdfLut.x + brdfLut.y) * iblFactor.y);
  3858. #ifdef USE_SUN_LUMINANCE
  3859. color += IBLColor * luminance;
  3860. #else
  3861. color += IBLColor;
  3862. #endif // end of USE_SUN_LUMINANCE
  3863. #endif // end of USE_IBL_LIGHTING
  3864. #ifdef HAS_OCCLUSION_TEXTURE
  3865. color *= texture2D(u_occlusionTexture, texCoord).r;
  3866. #endif
  3867. #ifdef HAS_EMISSIVE_TEXTURE
  3868. vec2 emissiveTexCoord = texCoord;
  3869. emissiveTexCoord = emissiveTexCoord * u_emissiveUVOffsetAndTiling.zw + u_emissiveUVOffsetAndTiling.xy;
  3870. vec3 emissive = SRGBtoLINEAR3(texture2D(u_emissiveTexture, emissiveTexCoord).rgb);
  3871. emissive *= u_emissiveFactor.rgb;
  3872. color += emissive;
  3873. #else
  3874. color += u_emissiveFactor.rgb;
  3875. #endif
  3876. color = LINEARtoSRGB(color);
  3877. vec4 resultColor = vec4(color, 1.0);
  3878. #ifdef MASK
  3879. if (baseColorWithAlpha.a < u_alphaCutoff)
  3880. {
  3881. discard;
  3882. }
  3883. resultColor = vec4(color, 1.0);
  3884. #endif
  3885. #ifdef BLEND
  3886. resultColor = vec4(color, baseColorWithAlpha.a);
  3887. #endif
  3888. return resultColor;
  3889. }`;var No=`uniform float uParentMixDirection;
  3890. uniform vec4 u_pickIDColor;
  3891. vec4 czm_sampleAndBlend(
  3892. vec4 previousColor,
  3893. sampler2D textureToSample,
  3894. vec2 tileTextureCoordinates,
  3895. vec4 textureCoordinateRectangle,
  3896. vec4 textureCoordinateTranslationAndScale,
  3897. vec4 transparentBackColor,
  3898. bool imageryClipEnable,
  3899. int rasterValue,
  3900. bool flipY,
  3901. float textureAlpha,
  3902. float textureBrightness,
  3903. float textureContrast,
  3904. float textureHue,
  3905. float textureSaturation,
  3906. float textureOneOverGamma,
  3907. vec2 split,
  3908. vec4 swipe,
  3909. float textureMinAlpha)
  3910. {
  3911. // This crazy step stuff sets the alpha to 0.0 if this following condition is true:
  3912. // tileTextureCoordinates.s < textureCoordinateRectangle.s ||
  3913. // tileTextureCoordinates.s > textureCoordinateRectangle.p ||
  3914. // tileTextureCoordinates.t < textureCoordinateRectangle.t ||
  3915. // tileTextureCoordinates.t > textureCoordinateRectangle.q
  3916. // In other words, the alpha is zero if the fragment is outside the rectangle
  3917. // covered by this texture. Would an actual 'if' yield better performance?
  3918. vec2 alphaMultiplier = step(textureCoordinateRectangle.st, tileTextureCoordinates);
  3919. textureAlpha = textureAlpha * alphaMultiplier.x * alphaMultiplier.y;
  3920. alphaMultiplier = step(vec2(0.0), textureCoordinateRectangle.pq - tileTextureCoordinates);
  3921. textureAlpha = textureAlpha * alphaMultiplier.x * alphaMultiplier.y;
  3922. vec2 translation = textureCoordinateTranslationAndScale.xy;
  3923. vec2 scale = textureCoordinateTranslationAndScale.zw;
  3924. vec2 textureCoordinates = tileTextureCoordinates * scale + translation;
  3925. if(flipY)
  3926. {
  3927. textureCoordinates.y = 1.0 - textureCoordinates.y;
  3928. }
  3929. vec4 value = texture2D(textureToSample, textureCoordinates);
  3930. vec3 color = value.rgb;
  3931. float alpha = value.a;
  3932. if(transparentBackColor.a > 0.01)
  3933. {
  3934. float rDiff = abs(transparentBackColor.r - color.r);
  3935. float gDiff = abs(transparentBackColor.g - color.g);
  3936. float bDiff = abs(transparentBackColor.b - color.b);
  3937. if(rDiff < transparentBackColor.a && gDiff < transparentBackColor.a && bDiff < transparentBackColor.a)
  3938. {
  3939. alpha = 0.0;
  3940. }
  3941. }
  3942. if(imageryClipEnable)
  3943. {
  3944. #ifdef Apply_ImageryClip
  3945. if((rasterValue & RASTER_CLIP_IMAGERY) < 1)
  3946. {
  3947. alpha = 0.0;
  3948. }
  3949. #else
  3950. alpha = 0.0;
  3951. #endif
  3952. }
  3953. #if !defined(APPLY_GAMMA)
  3954. vec4 tempColor = czm_gammaCorrect(vec4(color, alpha));
  3955. color = tempColor.rgb;
  3956. alpha = tempColor.a;
  3957. #else
  3958. color = pow(color, vec3(textureOneOverGamma));
  3959. #endif
  3960. #ifdef APPLY_SPLIT
  3961. vec2 splitPosition = czm_imagerySplitPosition;
  3962. // Split to the left
  3963. if (split.x < 0.0 && gl_FragCoord.x > splitPosition.x) {
  3964. alpha = 0.0;
  3965. }
  3966. // Split to the right
  3967. else if (split.x > 0.0 && gl_FragCoord.x < splitPosition.x) {
  3968. alpha = 0.0;
  3969. }
  3970. if(split.y < 0.0 && gl_FragCoord.y > splitPosition.y) {
  3971. alpha = 0.0;
  3972. }
  3973. else if(split.y > 0.0 && gl_FragCoord.y < splitPosition.y) {
  3974. alpha = 0.0;
  3975. }
  3976. #if TEXTURE_UNITS < 2
  3977. if(alpha == 0.0)
  3978. {
  3979. discard;
  3980. }
  3981. #endif
  3982. #endif
  3983. #ifdef APPLY_SWIPE
  3984. if (gl_FragCoord.x < swipe.x || gl_FragCoord.y > swipe.y) {
  3985. alpha = 0.0;
  3986. }
  3987. else if (gl_FragCoord.x > swipe.z || gl_FragCoord.y < swipe.w) {
  3988. alpha = 0.0;
  3989. }
  3990. #if TEXTURE_UNITS < 2
  3991. if(alpha == 0.0)
  3992. {
  3993. discard;
  3994. }
  3995. #endif
  3996. #endif
  3997. #ifdef APPLY_BRIGHTNESS
  3998. color = mix(vec3(0.0), color, textureBrightness);
  3999. #endif
  4000. #ifdef APPLY_CONTRAST
  4001. color = mix(vec3(0.5), color, textureContrast);
  4002. #endif
  4003. #ifdef APPLY_HUE
  4004. color = czm_hue(color, textureHue);
  4005. #endif
  4006. #ifdef APPLY_SATURATION
  4007. color = czm_saturation(color, textureSaturation);
  4008. #endif
  4009. #ifdef ALPHAFILTER
  4010. if(alpha <= textureMinAlpha)
  4011. {
  4012. return previousColor.rgba;
  4013. }
  4014. #endif
  4015. float sourceAlpha = alpha * textureAlpha;
  4016. float outAlpha = mix(previousColor.a, 1.0, sourceAlpha);
  4017. if(outAlpha < 0.1){
  4018. return vec4(0.0);
  4019. }
  4020. vec3 outColor = mix(previousColor.rgb * previousColor.a, color, sourceAlpha) / outAlpha;
  4021. return vec4(outColor, outAlpha);
  4022. }
  4023. vec4 sampleAndBlendParent(
  4024. vec4 previousColor,
  4025. sampler2D textureToSample,
  4026. vec2 tileTextureCoordinates,
  4027. vec4 textureCoordinateRectangle,
  4028. vec4 textureCoordinateTranslationAndScale,
  4029. vec4 transparentBackColor,
  4030. bool flipY,
  4031. float textureAlpha,
  4032. float textureBrightness,
  4033. float textureContrast,
  4034. float textureHue,
  4035. float textureSaturation,
  4036. float textureOneOverGamma,
  4037. vec2 split,
  4038. vec4 swipe,
  4039. float textureMinAlpha)
  4040. {
  4041. // This crazy step stuff sets the alpha to 0.0 if this following condition is true:
  4042. // tileTextureCoordinates.s < textureCoordinateRectangle.s ||
  4043. // tileTextureCoordinates.s > textureCoordinateRectangle.p ||
  4044. // tileTextureCoordinates.t < textureCoordinateRectangle.t ||
  4045. // tileTextureCoordinates.t > textureCoordinateRectangle.q
  4046. // In other words, the alpha is zero if the fragment is outside the rectangle
  4047. // covered by this texture. Would an actual 'if' yield better performance?
  4048. vec2 alphaMultiplier = step(textureCoordinateRectangle.st, tileTextureCoordinates);
  4049. textureAlpha = textureAlpha * alphaMultiplier.x * alphaMultiplier.y;
  4050. alphaMultiplier = step(vec2(0.0), textureCoordinateRectangle.pq - tileTextureCoordinates);
  4051. textureAlpha = textureAlpha * alphaMultiplier.x * alphaMultiplier.y;
  4052. vec2 translation = textureCoordinateTranslationAndScale.xy;
  4053. vec2 scale = textureCoordinateTranslationAndScale.zw;
  4054. vec2 textureCoordinates = tileTextureCoordinates * scale + translation;
  4055. if(flipY)
  4056. {
  4057. textureCoordinates.y = 1.0 - textureCoordinates.y;
  4058. }
  4059. vec4 value = texture2D(textureToSample, textureCoordinates);
  4060. if(uParentMixDirection > 0.0 && value.a > 0.01)
  4061. {
  4062. value.a = 0.0;
  4063. bool blend = false;
  4064. float mixDirection = uParentMixDirection;
  4065. if( mixDirection > 7.0 )
  4066. {
  4067. //\u5357
  4068. if(tileTextureCoordinates.y <0.3)
  4069. {
  4070. blend = true;
  4071. }
  4072. mixDirection-=8.0;
  4073. }
  4074. else if( mixDirection > 3.0)
  4075. {
  4076. //\u5317
  4077. if(tileTextureCoordinates.y >0.7)
  4078. {
  4079. blend = true;
  4080. }
  4081. mixDirection-=4.0;
  4082. }
  4083. if(blend)
  4084. {
  4085. //\u7EB9\u7406\u5750\u68070-0.5\uFF0C\u4E2D\u5FC3\u662F0\u8FB9\u7F18\u662F0.5
  4086. float mixY = abs(tileTextureCoordinates.y-0.5);
  4087. //mixValue0-5\uFF0C\u4E2D\u5FC3\u662F0\u8FB9\u7F18\u662F5
  4088. float mixValue = 10.0*mixY;
  4089. //mixValue0-1\uFF0C\u4E2D\u5FC3\u662F0\u8FB9\u7F183/5\u5904\u5F00\u59CB0-1\u6E10\u53D8
  4090. //mixValue = clamp(0.5*(mixValue - 3.0), 0.0, 1.0);
  4091. mixValue = clamp((mixValue - 4.0), 0.0, 1.0);
  4092. value.a = mixValue;
  4093. }
  4094. blend = false;
  4095. if( mixDirection > 1.5)
  4096. {
  4097. //\u4E1C
  4098. if(tileTextureCoordinates.x >0.7)
  4099. {
  4100. blend = true;
  4101. }
  4102. mixDirection-=2.0;
  4103. }
  4104. else if( mixDirection > 0.5)
  4105. {
  4106. //\u897F
  4107. if(tileTextureCoordinates.x <0.3)
  4108. {
  4109. blend = true;
  4110. }
  4111. }
  4112. if(blend)
  4113. {
  4114. float mixValue = 10.0*abs(tileTextureCoordinates.x-0.5);
  4115. mixValue = clamp((mixValue - 4.0), 0.0, 1.0);
  4116. value.a = max(mixValue, value.a);
  4117. }
  4118. }
  4119. vec3 color = value.rgb;
  4120. float alpha = value.a;
  4121. if(transparentBackColor.a > 0.01)
  4122. {
  4123. float rDiff = abs(transparentBackColor.r - color.r);
  4124. float gDiff = abs(transparentBackColor.g - color.g);
  4125. float bDiff = abs(transparentBackColor.b - color.b);
  4126. if(rDiff < transparentBackColor.a && gDiff < transparentBackColor.a && bDiff < transparentBackColor.a)
  4127. {
  4128. alpha = 0.0;
  4129. }
  4130. }
  4131. #if !defined(APPLY_GAMMA)
  4132. vec4 tempColor = czm_gammaCorrect(vec4(color, alpha));
  4133. color = tempColor.rgb;
  4134. alpha = tempColor.a;
  4135. #else
  4136. color = pow(color, vec3(textureOneOverGamma));
  4137. #endif
  4138. #ifdef APPLY_SPLIT
  4139. vec2 splitPosition = czm_imagerySplitPosition;
  4140. // Split to the left
  4141. if (split.x < 0.0 && gl_FragCoord.x > splitPosition.x) {
  4142. alpha = 0.0;
  4143. }
  4144. // Split to the right
  4145. else if (split.x > 0.0 && gl_FragCoord.x < splitPosition.x) {
  4146. alpha = 0.0;
  4147. }
  4148. if(split.y < 0.0 && gl_FragCoord.y > splitPosition.y) {
  4149. alpha = 0.0;
  4150. }
  4151. else if(split.y > 0.0 && gl_FragCoord.y < splitPosition.y) {
  4152. alpha = 0.0;
  4153. }
  4154. #if TEXTURE_UNITS < 2
  4155. if(alpha == 0.0)
  4156. {
  4157. discard;
  4158. }
  4159. #endif
  4160. #endif
  4161. #ifdef APPLY_SWIPE
  4162. if (gl_FragCoord.x < swipe.x || gl_FragCoord.y > swipe.y) {
  4163. alpha = 0.0;
  4164. }
  4165. else if (gl_FragCoord.x > swipe.z || gl_FragCoord.y < swipe.w) {
  4166. alpha = 0.0;
  4167. }
  4168. #if TEXTURE_UNITS < 2
  4169. if(alpha == 0.0)
  4170. {
  4171. discard;
  4172. }
  4173. #endif
  4174. #endif
  4175. #ifdef APPLY_BRIGHTNESS
  4176. color = mix(vec3(0.0), color, textureBrightness);
  4177. #endif
  4178. #ifdef APPLY_CONTRAST
  4179. color = mix(vec3(0.5), color, textureContrast);
  4180. #endif
  4181. #ifdef APPLY_HUE
  4182. color = czm_hue(color, textureHue);
  4183. #endif
  4184. #ifdef APPLY_SATURATION
  4185. color = czm_saturation(color, textureSaturation);
  4186. #endif
  4187. #ifdef ALPHAFILTER
  4188. if(alpha <= textureMinAlpha)
  4189. {
  4190. return previousColor.rgba;
  4191. }
  4192. #endif
  4193. float sourceAlpha = alpha * textureAlpha;
  4194. float outAlpha = mix(previousColor.a, 1.0, sourceAlpha);
  4195. vec3 outColor = mix(previousColor.rgb * previousColor.a, color, sourceAlpha) / outAlpha;
  4196. return vec4(outColor, outAlpha);
  4197. }
  4198. vec4 mvtTextureSampleAndBlend(
  4199. vec4 previousColor,
  4200. sampler2D textureToSample,
  4201. sampler2D idTextureToSample,
  4202. vec2 tileTextureCoordinates,
  4203. vec4 textureCoordinateRectangle,
  4204. vec4 textureCoordinateTranslationAndScale,
  4205. vec4 selectColor,
  4206. float textureAlpha,
  4207. float textureOneOverGamma,
  4208. vec4 swipe)
  4209. {
  4210. #ifdef APPLY_SWIPE
  4211. vec2 f = step(swipe.xw, vec2(gl_FragCoord.xy));
  4212. vec2 s = step(vec2(gl_FragCoord.xy), swipe.zy);
  4213. if (f.x * f.y * s.x * s.y < 1.0) {
  4214. return previousColor;
  4215. };
  4216. #endif
  4217. vec2 alphaMultiplier = step(textureCoordinateRectangle.st, tileTextureCoordinates);
  4218. textureAlpha = textureAlpha * alphaMultiplier.x * alphaMultiplier.y;
  4219. alphaMultiplier = step(vec2(0.0), textureCoordinateRectangle.pq - tileTextureCoordinates);
  4220. textureAlpha = textureAlpha * alphaMultiplier.x * alphaMultiplier.y;
  4221. vec2 translation = textureCoordinateTranslationAndScale.xy;
  4222. vec2 scale = textureCoordinateTranslationAndScale.zw;
  4223. vec2 textureCoordinates = tileTextureCoordinates * scale + translation;
  4224. vec4 value = texture2D(textureToSample, textureCoordinates);
  4225. vec4 idColor = texture2D(idTextureToSample, textureCoordinates);
  4226. if(idColor.r == u_pickIDColor.r && idColor.g == u_pickIDColor.g && idColor.b == u_pickIDColor.b){
  4227. value.rgb = selectColor.rgb;
  4228. }
  4229. vec3 color = value.rgb;
  4230. float alpha = value.a;
  4231. #if !defined(APPLY_GAMMA)
  4232. vec4 tempColor = czm_gammaCorrect(vec4(color, alpha));
  4233. color = tempColor.rgb;
  4234. alpha = tempColor.a;
  4235. #else
  4236. color = pow(color, vec3(textureOneOverGamma));
  4237. #endif
  4238. float sourceAlpha = alpha * textureAlpha;
  4239. float outAlpha = mix(previousColor.a, 1.0, sourceAlpha);
  4240. vec3 outColor = mix(previousColor.rgb * previousColor.a, color, sourceAlpha) / outAlpha;
  4241. return vec4(outColor, outAlpha);
  4242. }
  4243. vec4 gridTextureSampleAndBlend(
  4244. vec4 previousColor,
  4245. sampler2D textureToSample,
  4246. vec2 tileTextureCoordinates,
  4247. vec4 textureCoordinateRectangle,
  4248. vec4 textureCoordinateTranslationAndScale)
  4249. {
  4250. float textureAlpha = 1.0;
  4251. vec2 alphaMultiplier = step(textureCoordinateRectangle.st, tileTextureCoordinates);
  4252. textureAlpha = textureAlpha * alphaMultiplier.x * alphaMultiplier.y;
  4253. alphaMultiplier = step(vec2(0.0), textureCoordinateRectangle.pq - tileTextureCoordinates);
  4254. textureAlpha = textureAlpha * alphaMultiplier.x * alphaMultiplier.y;
  4255. vec2 translation = textureCoordinateTranslationAndScale.xy;
  4256. vec2 scale = textureCoordinateTranslationAndScale.zw;
  4257. vec2 textureCoordinates = tileTextureCoordinates * scale + translation;
  4258. vec4 value = texture2D(textureToSample, textureCoordinates);
  4259. vec3 color = value.rgb;
  4260. float alpha = value.a;
  4261. float sourceAlpha = alpha * textureAlpha;
  4262. float outAlpha = mix(previousColor.a, 1.0, sourceAlpha);
  4263. vec3 outColor = mix(previousColor.rgb * previousColor.a, color, sourceAlpha) / outAlpha;
  4264. return vec4(outColor, outAlpha);
  4265. }`;var Ho=`/**
  4266. * Samples the 4 neighboring pixels and return the weighted average.
  4267. *
  4268. * @private
  4269. */
  4270. vec3 czm_sampleOctahedralProjectionWithFiltering(sampler2D projectedMap, vec2 textureSize, vec3 direction, float lod)
  4271. {
  4272. direction /= dot(vec3(1.0), abs(direction));
  4273. vec2 rev = abs(direction.zx) - vec2(1.0);
  4274. vec2 neg = vec2(direction.x < 0.0 ? rev.x : -rev.x,
  4275. direction.z < 0.0 ? rev.y : -rev.y);
  4276. vec2 uv = direction.y < 0.0 ? neg : direction.xz;
  4277. vec2 coord = 0.5 * uv + vec2(0.5);
  4278. vec2 pixel = 1.0 / textureSize;
  4279. if (lod > 0.0)
  4280. {
  4281. // Each subseqeuent mip level is half the size
  4282. float scale = 1.0 / pow(2.0, lod);
  4283. float offset = ((textureSize.y + 1.0) / textureSize.x);
  4284. coord.x *= offset;
  4285. coord *= scale;
  4286. coord.x += offset + pixel.x;
  4287. coord.y += (1.0 - (1.0 / pow(2.0, lod - 1.0))) + pixel.y * (lod - 1.0) * 2.0;
  4288. }
  4289. else
  4290. {
  4291. coord.x *= (textureSize.y / textureSize.x);
  4292. }
  4293. // Do bilinear filtering
  4294. #ifndef OES_texture_float_linear
  4295. vec3 color1 = texture2D(projectedMap, coord + vec2(0.0, pixel.y)).rgb;
  4296. vec3 color2 = texture2D(projectedMap, coord + vec2(pixel.x, 0.0)).rgb;
  4297. vec3 color3 = texture2D(projectedMap, coord + pixel).rgb;
  4298. vec3 color4 = texture2D(projectedMap, coord).rgb;
  4299. vec2 texturePosition = coord * textureSize;
  4300. float fu = fract(texturePosition.x);
  4301. float fv = fract(texturePosition.y);
  4302. vec3 average1 = mix(color4, color2, fu);
  4303. vec3 average2 = mix(color1, color3, fu);
  4304. vec3 color = mix(average1, average2, fv);
  4305. #else
  4306. vec3 color = texture2D(projectedMap, coord).rgb;
  4307. #endif
  4308. return color;
  4309. }
  4310. /**
  4311. * Samples from a cube map that has been projected using an octahedral projection from the given direction.
  4312. *
  4313. * @name czm_sampleOctahedralProjection
  4314. * @glslFunction
  4315. *
  4316. * @param {sampler2D} projectedMap The texture with the octahedral projected cube map.
  4317. * @param {vec2} textureSize The width and height dimensions in pixels of the projected map.
  4318. * @param {vec3} direction The normalized direction used to sample the cube map.
  4319. * @param {float} lod The level of detail to sample.
  4320. * @param {float} maxLod The maximum level of detail.
  4321. * @returns {vec3} The color of the cube map at the direction.
  4322. */
  4323. vec3 czm_sampleOctahedralProjection(sampler2D projectedMap, vec2 textureSize, vec3 direction, float lod, float maxLod) {
  4324. float currentLod = floor(lod + 0.5);
  4325. float nextLod = min(currentLod + 1.0, maxLod);
  4326. vec3 colorCurrentLod = czm_sampleOctahedralProjectionWithFiltering(projectedMap, textureSize, direction, currentLod);
  4327. vec3 colorNextLod = czm_sampleOctahedralProjectionWithFiltering(projectedMap, textureSize, direction, nextLod);
  4328. return mix(colorNextLod, colorCurrentLod, nextLod - lod);
  4329. }
  4330. `;var Uo=`/**
  4331. * Adjusts the saturation of a color.
  4332. *
  4333. * @name czm_saturation
  4334. * @glslFunction
  4335. *
  4336. * @param {vec3} rgb The color.
  4337. * @param {float} adjustment The amount to adjust the saturation of the color.
  4338. *
  4339. * @returns {float} The color with the saturation adjusted.
  4340. *
  4341. * @example
  4342. * vec3 greyScale = czm_saturation(color, 0.0);
  4343. * vec3 doubleSaturation = czm_saturation(color, 2.0);
  4344. */
  4345. vec3 czm_saturation(vec3 rgb, float adjustment)
  4346. {
  4347. // Algorithm from Chapter 16 of OpenGL Shading Language
  4348. const vec3 W = vec3(0.2125, 0.7154, 0.0721);
  4349. vec3 intensity = vec3(dot(rgb, W));
  4350. return mix(intensity, rgb, adjustment);
  4351. }
  4352. `;var Go=`
  4353. float czm_sampleShadowMap(samplerCube shadowMap, vec3 d)
  4354. {
  4355. return czm_unpackDepth(textureCube(shadowMap, d));
  4356. }
  4357. float czm_sampleShadowMap(sampler2D shadowMap, vec2 uv)
  4358. {
  4359. #ifdef USE_SHADOW_DEPTH_TEXTURE
  4360. return texture2D(shadowMap, uv).r;
  4361. #else
  4362. return czm_unpackDepth(texture2D(shadowMap, uv));
  4363. #endif
  4364. }
  4365. float czm_shadowDepthCompare(samplerCube shadowMap, vec3 uv, float depth)
  4366. {
  4367. return step(depth, czm_sampleShadowMap(shadowMap, uv));
  4368. }
  4369. float czm_shadowDepthCompare(sampler2D shadowMap, vec2 uv, float depth)
  4370. {
  4371. return step(depth, czm_sampleShadowMap(shadowMap, uv));
  4372. }
  4373. `;var ko=`
  4374. float czm_private_shadowVisibility(float visibility, float nDotL, float normalShadingSmooth, float darkness)
  4375. {
  4376. #ifdef USE_NORMAL_SHADING
  4377. #ifdef USE_NORMAL_SHADING_SMOOTH
  4378. float strength = clamp(nDotL / normalShadingSmooth, 0.0, 1.0);
  4379. #else
  4380. float strength = step(0.0, nDotL);
  4381. #endif
  4382. visibility *= strength;
  4383. #endif
  4384. visibility = max(visibility, darkness);
  4385. return visibility;
  4386. }
  4387. #ifdef USE_CUBE_MAP_SHADOW
  4388. float czm_shadowVisibility(samplerCube shadowMap, czm_shadowParameters shadowParameters)
  4389. {
  4390. float depthBias = shadowParameters.depthBias;
  4391. float depth = shadowParameters.depth;
  4392. float nDotL = shadowParameters.nDotL;
  4393. float normalShadingSmooth = shadowParameters.normalShadingSmooth;
  4394. float darkness = shadowParameters.darkness;
  4395. vec3 uvw = shadowParameters.texCoords;
  4396. depth -= depthBias;
  4397. float visibility = czm_shadowDepthCompare(shadowMap, uvw, depth);
  4398. return czm_private_shadowVisibility(visibility, nDotL, normalShadingSmooth, darkness);
  4399. }
  4400. #else
  4401. float czm_shadowVisibility(sampler2D shadowMap, czm_shadowParameters shadowParameters)
  4402. {
  4403. float depthBias = shadowParameters.depthBias;
  4404. float depth = shadowParameters.depth;
  4405. float nDotL = shadowParameters.nDotL;
  4406. float normalShadingSmooth = shadowParameters.normalShadingSmooth;
  4407. float darkness = shadowParameters.darkness;
  4408. vec2 uv = shadowParameters.texCoords;
  4409. depth -= depthBias;
  4410. #ifdef USE_SOFT_SHADOWS
  4411. vec2 texelStepSize = shadowParameters.texelStepSize;
  4412. float radius = 1.0;
  4413. float dx0 = -texelStepSize.x * radius;
  4414. float dy0 = -texelStepSize.y * radius;
  4415. float dx1 = texelStepSize.x * radius;
  4416. float dy1 = texelStepSize.y * radius;
  4417. float visibility = (
  4418. czm_shadowDepthCompare(shadowMap, uv, depth) +
  4419. czm_shadowDepthCompare(shadowMap, uv + vec2(dx0, dy0), depth) +
  4420. czm_shadowDepthCompare(shadowMap, uv + vec2(0.0, dy0), depth) +
  4421. czm_shadowDepthCompare(shadowMap, uv + vec2(dx1, dy0), depth) +
  4422. czm_shadowDepthCompare(shadowMap, uv + vec2(dx0, 0.0), depth) +
  4423. czm_shadowDepthCompare(shadowMap, uv + vec2(dx1, 0.0), depth) +
  4424. czm_shadowDepthCompare(shadowMap, uv + vec2(dx0, dy1), depth) +
  4425. czm_shadowDepthCompare(shadowMap, uv + vec2(0.0, dy1), depth) +
  4426. czm_shadowDepthCompare(shadowMap, uv + vec2(dx1, dy1), depth)
  4427. ) * (1.0 / 9.0);
  4428. #else
  4429. float visibility = czm_shadowDepthCompare(shadowMap, uv, depth);
  4430. #endif
  4431. return czm_private_shadowVisibility(visibility, nDotL, normalShadingSmooth, darkness);
  4432. }
  4433. #endif
  4434. `;var Wo=`/**
  4435. * Returns 1.0 if the given value is positive or zero, and -1.0 if it is negative. This is similar to the GLSL
  4436. * built-in function <code>sign</code> except that returns 1.0 instead of 0.0 when the input value is 0.0.
  4437. *
  4438. * @name czm_signNotZero
  4439. * @glslFunction
  4440. *
  4441. * @param {} value The value for which to determine the sign.
  4442. * @returns {} 1.0 if the value is positive or zero, -1.0 if the value is negative.
  4443. */
  4444. float czm_signNotZero(float value)
  4445. {
  4446. return value >= 0.0 ? 1.0 : -1.0;
  4447. }
  4448. vec2 czm_signNotZero(vec2 value)
  4449. {
  4450. return vec2(czm_signNotZero(value.x), czm_signNotZero(value.y));
  4451. }
  4452. vec3 czm_signNotZero(vec3 value)
  4453. {
  4454. return vec3(czm_signNotZero(value.x), czm_signNotZero(value.y), czm_signNotZero(value.z));
  4455. }
  4456. vec4 czm_signNotZero(vec4 value)
  4457. {
  4458. return vec4(czm_signNotZero(value.x), czm_signNotZero(value.y), czm_signNotZero(value.z), czm_signNotZero(value.w));
  4459. }
  4460. `;var qo=`uniform sampler2D uNormalDepthTexture;
  4461. uniform int uFillStyle;
  4462. float edgeDetection(float lineWidth)
  4463. {
  4464. vec2 center = gl_FragCoord.xy / czm_globeDepthTextureDim.xy;
  4465. vec2 off = lineWidth / czm_globeDepthTextureDim.xy;
  4466. vec4 tex_nw = vec4(center.x+off.x, center.y+off.y, 1.0, 1.0);
  4467. vec4 val_nw = texture2D(uNormalDepthTexture, tex_nw.xy);
  4468. val_nw.xyz = (val_nw.xyz * 2.0) - 1.0;
  4469. vec4 tex_ne = vec4(center.x-off.x, center.y+off.y, 1.0, 1.0);
  4470. vec4 val_ne = texture2D(uNormalDepthTexture, tex_ne.xy);
  4471. val_ne.xyz = (val_ne.xyz * 2.0) - 1.0;
  4472. vec4 tex_sw = vec4(center.x+off.x, center.y-off.y, 1.0, 1.0);
  4473. vec4 val_sw = texture2D(uNormalDepthTexture, tex_sw.xy);
  4474. val_sw.xyz = (val_sw.xyz * 2.0 ) - 1.0;
  4475. vec4 tex_se = vec4(center.x-off.x, center.y-off.y, 1.0, 1.0);
  4476. vec4 val_se = texture2D(uNormalDepthTexture, tex_se.xy);
  4477. val_se.xyz = (val_se.xyz * 2.0) - 1.0;
  4478. float discontinuity = 0.0;
  4479. float dot0 = dot(val_nw.xyz, val_se.xyz);
  4480. float dot1 = dot(val_ne.xyz, val_sw.xyz);
  4481. discontinuity = 0.5*(dot0+dot1);
  4482. return discontinuity;
  4483. }
  4484. vec4 czm_sketchMode(vec4 inputColor, vec4 lineColor, float lineWidth)
  4485. {
  4486. vec4 outputColor = inputColor;
  4487. float discontinuity = edgeDetection(lineWidth);
  4488. discontinuity = clamp(discontinuity, 0.0, 1.0);
  4489. if(uFillStyle == 1)
  4490. {
  4491. outputColor = lineColor;
  4492. outputColor.a = (1.0 - sign(discontinuity - 0.5)) * 0.5;
  4493. outputColor.a *= lineColor.a;
  4494. }
  4495. else
  4496. {
  4497. vec3 mixLineColor = mix(inputColor.rgb, vec3(lineColor.rgb), lineColor.a);
  4498. outputColor.rgb = mix(mixLineColor, inputColor.rgb, discontinuity);
  4499. }
  4500. return outputColor;
  4501. }`;var Xo=`/**
  4502. * Computes a color from the third order spherical harmonic coefficients and a normalized direction vector.
  4503. * <p>
  4504. * The order of the coefficients is [L00, L1_1, L10, L11, L2_2, L2_1, L20, L21, L22].
  4505. * </p>
  4506. *
  4507. * @name czm_sphericalHarmonics
  4508. * @glslFunction
  4509. *
  4510. * @param {vec3} normal The normalized direction.
  4511. * @param {vec3[9]} coefficients The third order spherical harmonic coefficients.
  4512. * @returns {vec3} The color at the direction.
  4513. *
  4514. */
  4515. vec3 czm_sphericalHarmonics(vec3 normal, vec3 coefficients[9])
  4516. {
  4517. const float c1 = 0.429043;
  4518. const float c2 = 0.511664;
  4519. const float c3 = 0.743125;
  4520. const float c4 = 0.886227;
  4521. const float c5 = 0.247708;
  4522. vec3 L00 = coefficients[0];
  4523. vec3 L1_1 = coefficients[1];
  4524. vec3 L10 = coefficients[2];
  4525. vec3 L11 = coefficients[3];
  4526. vec3 L2_2 = coefficients[4];
  4527. vec3 L2_1 = coefficients[5];
  4528. vec3 L20 = coefficients[6];
  4529. vec3 L21 = coefficients[7];
  4530. vec3 L22 = coefficients[8];
  4531. float x = normal.x;
  4532. float y = normal.y;
  4533. float z = normal.z;
  4534. return c1 * L22 * (x * x - y * y) + c3 * L20 * z * z + c4 * L00 - c5 * L20 +
  4535. 2.0 * c1 * (L2_2 * x * y + L21 * x * z + L2_1 * y * z) +
  4536. 2.0 * c2 * (L11 * x + L1_1 * y + L10 * z);
  4537. }
  4538. `;var Yo=`/**
  4539. * Creates a matrix that transforms vectors from tangent space to eye space.
  4540. *
  4541. * @name czm_tangentToEyeSpaceMatrix
  4542. * @glslFunction
  4543. *
  4544. * @param {vec3} normalEC The normal vector in eye coordinates.
  4545. * @param {vec3} tangentEC The tangent vector in eye coordinates.
  4546. * @param {vec3} bitangentEC The bitangent vector in eye coordinates.
  4547. *
  4548. * @returns {mat3} The matrix that transforms from tangent space to eye space.
  4549. *
  4550. * @example
  4551. * mat3 tangentToEye = czm_tangentToEyeSpaceMatrix(normalEC, tangentEC, bitangentEC);
  4552. * vec3 normal = tangentToEye * texture2D(normalMap, st).xyz;
  4553. */
  4554. mat3 czm_tangentToEyeSpaceMatrix(vec3 normalEC, vec3 tangentEC, vec3 bitangentEC)
  4555. {
  4556. vec3 normal = normalize(normalEC);
  4557. vec3 tangent = normalize(tangentEC);
  4558. vec3 bitangent = normalize(bitangentEC);
  4559. return mat3(tangent.x , tangent.y , tangent.z,
  4560. bitangent.x, bitangent.y, bitangent.z,
  4561. normal.x , normal.y , normal.z);
  4562. }
  4563. `;var jo=`vec4 czm_transformPlane(vec4 clippingPlane, mat4 transform) {
  4564. vec3 transformedDirection = normalize((transform * vec4(clippingPlane.xyz, 0.0)).xyz);
  4565. vec3 transformedPosition = (transform * vec4(clippingPlane.xyz * -clippingPlane.w, 1.0)).xyz;
  4566. vec4 transformedPlane;
  4567. transformedPlane.xyz = transformedDirection;
  4568. transformedPlane.w = -dot(transformedDirection, transformedPosition);
  4569. return transformedPlane;
  4570. }
  4571. `;var Zo=`/**
  4572. * Translates a position (or any <code>vec3</code>) that was encoded with {@link EncodedCartesian3},
  4573. * and then provided to the shader as separate <code>high</code> and <code>low</code> bits to
  4574. * be relative to the eye. As shown in the example, the position can then be transformed in eye
  4575. * or clip coordinates using {@link czm_modelViewRelativeToEye} or {@link czm_modelViewProjectionRelativeToEye},
  4576. * respectively.
  4577. * <p>
  4578. * This technique, called GPU RTE, eliminates jittering artifacts when using large coordinates as
  4579. * described in .
  4580. * </p>
  4581. *
  4582. * @name czm_translateRelativeToEye
  4583. * @glslFunction
  4584. *
  4585. * @param {vec3} high The position's high bits.
  4586. * @param {vec3} low The position's low bits.
  4587. * @returns {vec3} The position translated to be relative to the camera's position.
  4588. *
  4589. * @example
  4590. * attribute vec3 positionHigh;
  4591. * attribute vec3 positionLow;
  4592. *
  4593. * void main()
  4594. * {
  4595. * vec4 p = czm_translateRelativeToEye(positionHigh, positionLow);
  4596. * gl_Position = czm_modelViewProjectionRelativeToEye * p;
  4597. * }
  4598. *
  4599. * @see czm_modelViewRelativeToEye
  4600. * @see czm_modelViewProjectionRelativeToEye
  4601. * @see czm_computePosition
  4602. * @see EncodedCartesian3
  4603. */
  4604. vec4 czm_translateRelativeToEye(vec3 high, vec3 low)
  4605. {
  4606. vec3 highDifference = high - czm_encodedCameraPositionMCHigh;
  4607. // This check handles the case when NaN values have gotten into \`highDifference\`
  4608. // Such a thing could happen on devices running iOS
  4609. if(length(highDifference) == 0.0) {
  4610. highDifference = vec3(0);
  4611. }
  4612. vec3 lowDifference = low - czm_encodedCameraPositionMCLow;
  4613. return vec4(highDifference + lowDifference, 1.0);
  4614. }
  4615. `;var Ko=`/**
  4616. * @private
  4617. */
  4618. vec4 czm_translucentPhong(vec3 toEye, czm_material material, vec3 lightDirectionEC)
  4619. {
  4620. // Diffuse from directional light sources at eye (for top-down and horizon views)
  4621. float diffuse = czm_getLambertDiffuse(vec3(0.0, 0.0, 1.0), material.normal);
  4622. if (czm_sceneMode == czm_sceneMode3D) {
  4623. // (and horizon views in 3D)
  4624. diffuse += czm_getLambertDiffuse(vec3(0.0, 1.0, 0.0), material.normal);
  4625. }
  4626. diffuse = clamp(diffuse, 0.0, 1.0);
  4627. float specular = czm_getSpecular(lightDirectionEC, toEye, material.normal, material.shininess);
  4628. // Temporary workaround for adding ambient.
  4629. vec3 materialDiffuse = material.diffuse * 0.5;
  4630. vec3 ambient = materialDiffuse;
  4631. vec3 color = ambient + material.emission;
  4632. color += materialDiffuse * diffuse * czm_lightColor;
  4633. color += material.specular * specular * czm_lightColor;
  4634. return vec4(color, material.alpha);
  4635. }
  4636. `;var Qo=`/**
  4637. * Returns the transpose of the matrix. The input <code>matrix</code> can be
  4638. * a <code>mat2</code>, <code>mat3</code>, or <code>mat4</code>.
  4639. *
  4640. * @name czm_transpose
  4641. * @glslFunction
  4642. *
  4643. * @param {} matrix The matrix to transpose.
  4644. *
  4645. * @returns {} The transposed matrix.
  4646. *
  4647. * @example
  4648. * // GLSL declarations
  4649. * mat2 czm_transpose(mat2 matrix);
  4650. * mat3 czm_transpose(mat3 matrix);
  4651. * mat4 czm_transpose(mat4 matrix);
  4652. *
  4653. * // Transpose a 3x3 rotation matrix to find its inverse.
  4654. * mat3 eastNorthUpToEye = czm_eastNorthUpToEyeCoordinates(
  4655. * positionMC, normalEC);
  4656. * mat3 eyeToEastNorthUp = czm_transpose(eastNorthUpToEye);
  4657. */
  4658. mat2 czm_transpose(mat2 matrix)
  4659. {
  4660. return mat2(
  4661. matrix[0][0], matrix[1][0],
  4662. matrix[0][1], matrix[1][1]);
  4663. }
  4664. mat3 czm_transpose(mat3 matrix)
  4665. {
  4666. return mat3(
  4667. matrix[0][0], matrix[1][0], matrix[2][0],
  4668. matrix[0][1], matrix[1][1], matrix[2][1],
  4669. matrix[0][2], matrix[1][2], matrix[2][2]);
  4670. }
  4671. mat4 czm_transpose(mat4 matrix)
  4672. {
  4673. return mat4(
  4674. matrix[0][0], matrix[1][0], matrix[2][0], matrix[3][0],
  4675. matrix[0][1], matrix[1][1], matrix[2][1], matrix[3][1],
  4676. matrix[0][2], matrix[1][2], matrix[2][2], matrix[3][2],
  4677. matrix[0][3], matrix[1][3], matrix[2][3], matrix[3][3]);
  4678. }
  4679. `;var Jo=`/**
  4680. * Unpacks a vec4 depth value to a float in [0, 1) range.
  4681. *
  4682. * @name czm_unpackDepth
  4683. * @glslFunction
  4684. *
  4685. * @param {vec4} packedDepth The packed depth.
  4686. *
  4687. * @returns {float} The floating-point depth in [0, 1) range.
  4688. */
  4689. float czm_unpackDepth(vec4 packedDepth)
  4690. {
  4691. // See Aras Pranckevi\u010Dius' post Encoding Floats to RGBA
  4692. return dot(packedDepth, vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));
  4693. }
  4694. `;var $o=`#define SHIFT_RIGHT_8 0.00390625 //1.0 / 256.0
  4695. #define SHIFT_RIGHT_16 0.00001525878 //1.0 / 65536.0
  4696. #define SHIFT_RIGHT_24 5.960464477539063e-8//1.0 / 16777216.0
  4697. #define BIAS 38.0
  4698. /**
  4699. * Unpacks a vec4 value containing values expressable as uint8 to an arbitrary float.
  4700. *
  4701. * @name czm_unpackFloat
  4702. * @glslFunction
  4703. *
  4704. * @param {vec4} packedFloat The packed float.
  4705. *
  4706. * @returns {float} The floating-point depth in arbitrary range.
  4707. */
  4708. float czm_unpackFloat(vec4 packedFloat)
  4709. {
  4710. packedFloat *= 255.0;
  4711. float temp = packedFloat.w / 2.0;
  4712. float exponent = floor(temp);
  4713. float sign = (temp - exponent) * 2.0;
  4714. exponent = exponent - float(BIAS);
  4715. sign = sign * 2.0 - 1.0;
  4716. sign = -sign;
  4717. float unpacked = sign * packedFloat.x * float(SHIFT_RIGHT_8);
  4718. unpacked += sign * packedFloat.y * float(SHIFT_RIGHT_16);
  4719. unpacked += sign * packedFloat.z * float(SHIFT_RIGHT_24);
  4720. return unpacked * pow(10.0, exponent);
  4721. }
  4722. `;var er=`/**
  4723. * Unpacks a vec4 value to a float.
  4724. *
  4725. * @name czm_unpackValue
  4726. * @glslFunction
  4727. *
  4728. * @param {vec3} packedValue The packed value.
  4729. *
  4730. * @returns {float} The floating-point value.
  4731. */
  4732. float czm_unpackValue(vec4 packedValue)
  4733. {
  4734. float SHIFT_LEFT16 = 65536.0;
  4735. float SHIFT_LEFT8 = 256.0;
  4736. vec4 value = packedValue * 255.0;
  4737. return value.r * SHIFT_LEFT16 + value.g * SHIFT_LEFT8 + value.b - 9000.0;
  4738. }
  4739. `;var nr=`#ifdef LOG_DEPTH
  4740. // 1.0 at the near plane, increasing linearly from there.
  4741. varying float v_depthFromNearPlusOne;
  4742. #ifdef SHADOW_MAP
  4743. varying vec3 v_logPositionEC;
  4744. #endif
  4745. #endif
  4746. vec4 czm_updatePositionDepth(vec4 coords) {
  4747. #if defined(LOG_DEPTH)
  4748. #ifdef SHADOW_MAP
  4749. vec3 logPositionEC = (czm_inverseProjection * coords).xyz;
  4750. v_logPositionEC = logPositionEC;
  4751. #endif
  4752. // With the very high far/near ratios used with the logarithmic depth
  4753. // buffer, floating point rounding errors can cause linear depth values
  4754. // to end up on the wrong side of the far plane, even for vertices that
  4755. // are really nowhere near it. Since we always write a correct logarithmic
  4756. // depth value in the fragment shader anyway, we just need to make sure
  4757. // such errors don't cause the primitive to be clipped entirely before
  4758. // we even get to the fragment shader.
  4759. coords.z = clamp(coords.z / coords.w, -1.0, 1.0) * coords.w;
  4760. #endif
  4761. return coords;
  4762. }
  4763. /**
  4764. * Writes the logarithmic depth to gl_Position using the already computed gl_Position.
  4765. *
  4766. * @name czm_vertexLogDepth
  4767. * @glslFunction
  4768. */
  4769. void czm_vertexLogDepth()
  4770. {
  4771. #ifdef LOG_DEPTH
  4772. v_depthFromNearPlusOne = 1.0 - czm_currentFrustum.x + gl_Position.w;
  4773. gl_Position = czm_updatePositionDepth(gl_Position);
  4774. #endif
  4775. }
  4776. /**
  4777. * Writes the logarithmic depth to gl_Position using the provided clip coordinates.
  4778. * <p>
  4779. * An example use case for this function would be moving the vertex in window coordinates
  4780. * before converting back to clip coordinates. Use the original vertex clip coordinates.
  4781. * </p>
  4782. * @name czm_vertexLogDepth
  4783. * @glslFunction
  4784. *
  4785. * @param {vec4} clipCoords The vertex in clip coordinates.
  4786. *
  4787. * @example
  4788. * czm_vertexLogDepth(czm_projection * vec4(positionEyeCoordinates, 1.0));
  4789. */
  4790. void czm_vertexLogDepth(vec4 clipCoords)
  4791. {
  4792. #ifdef LOG_DEPTH
  4793. v_depthFromNearPlusOne = 1.0 - czm_currentFrustum.x + clipCoords.w;
  4794. czm_updatePositionDepth(clipCoords);
  4795. #endif
  4796. }
  4797. `;var tr=`/**
  4798. * Transforms a position from window to eye coordinates.
  4799. * The transform from window to normalized device coordinates is done using components
  4800. * of (@link czm_viewport} and {@link czm_viewportTransformation} instead of calculating
  4801. * the inverse of <code>czm_viewportTransformation</code>. The transformation from
  4802. * normalized device coordinates to clip coordinates is done using <code>fragmentCoordinate.w</code>,
  4803. * which is expected to be the scalar used in the perspective divide. The transformation
  4804. * from clip to eye coordinates is done using {@link czm_inverseProjection}.
  4805. *
  4806. * @name czm_windowToEyeCoordinates
  4807. * @glslFunction
  4808. *
  4809. * @param {vec4} fragmentCoordinate The position in window coordinates to transform.
  4810. *
  4811. * @returns {vec4} The transformed position in eye coordinates.
  4812. *
  4813. * @see czm_modelToWindowCoordinates
  4814. * @see czm_eyeToWindowCoordinates
  4815. * @see czm_inverseProjection
  4816. * @see czm_viewport
  4817. * @see czm_viewportTransformation
  4818. *
  4819. * @example
  4820. * vec4 positionEC = czm_windowToEyeCoordinates(gl_FragCoord);
  4821. */
  4822. vec4 czm_windowToEyeCoordinates(vec4 fragmentCoordinate)
  4823. {
  4824. // Reconstruct NDC coordinates
  4825. float x = 2.0 * (fragmentCoordinate.x - czm_viewport.x) / czm_viewport.z - 1.0;
  4826. float y = 2.0 * (fragmentCoordinate.y - czm_viewport.y) / czm_viewport.w - 1.0;
  4827. float z = (fragmentCoordinate.z - czm_viewportTransformation[3][2]) / czm_viewportTransformation[2][2];
  4828. vec4 q = vec4(x, y, z, 1.0);
  4829. // Reverse the perspective division to obtain clip coordinates.
  4830. q /= fragmentCoordinate.w;
  4831. // Reverse the projection transformation to obtain eye coordinates.
  4832. if (!(czm_inverseProjection == mat4(0.0))) // IE and Edge sometimes do something weird with != between mat4s
  4833. {
  4834. q = czm_inverseProjection * q;
  4835. }
  4836. else
  4837. {
  4838. float top = czm_frustumPlanes.x;
  4839. float bottom = czm_frustumPlanes.y;
  4840. float left = czm_frustumPlanes.z;
  4841. float right = czm_frustumPlanes.w;
  4842. float near = czm_currentFrustum.x;
  4843. float far = czm_currentFrustum.y;
  4844. q.x = (q.x * (right - left) + left + right) * 0.5;
  4845. q.y = (q.y * (top - bottom) + bottom + top) * 0.5;
  4846. q.z = (q.z * (near - far) - near - far) * 0.5;
  4847. q.w = 1.0;
  4848. }
  4849. return q;
  4850. }
  4851. /**
  4852. * Transforms a position given as window x/y and a depth or a log depth from window to eye coordinates.
  4853. * This function produces more accurate results for window positions with log depth than
  4854. * conventionally unpacking the log depth using czm_reverseLogDepth and using the standard version
  4855. * of czm_windowToEyeCoordinates.
  4856. *
  4857. * @name czm_windowToEyeCoordinates
  4858. * @glslFunction
  4859. *
  4860. * @param {vec2} fragmentCoordinateXY The XY position in window coordinates to transform.
  4861. * @param {float} depthOrLogDepth A depth or log depth for the fragment.
  4862. *
  4863. * @see czm_modelToWindowCoordinates
  4864. * @see czm_eyeToWindowCoordinates
  4865. * @see czm_inverseProjection
  4866. * @see czm_viewport
  4867. * @see czm_viewportTransformation
  4868. *
  4869. * @returns {vec4} The transformed position in eye coordinates.
  4870. */
  4871. vec4 czm_windowToEyeCoordinates(vec2 fragmentCoordinateXY, float depthOrLogDepth)
  4872. {
  4873. // See reverseLogDepth.glsl. This is separate to re-use the pow.
  4874. #ifdef LOG_DEPTH
  4875. float near = czm_currentFrustum.x;
  4876. float far = czm_currentFrustum.y;
  4877. float log2Depth = depthOrLogDepth * czm_log2FarDepthFromNearPlusOne;
  4878. float depthFromNear = pow(2.0, log2Depth) - 1.0;
  4879. float depthFromCamera = depthFromNear + near;
  4880. vec4 windowCoord = vec4(fragmentCoordinateXY, far * (1.0 - near / depthFromCamera) / (far - near), 1.0);
  4881. vec4 eyeCoordinate = czm_windowToEyeCoordinates(windowCoord);
  4882. eyeCoordinate.w = 1.0 / depthFromCamera; // Better precision
  4883. return eyeCoordinate;
  4884. #else
  4885. vec4 windowCoord = vec4(fragmentCoordinateXY, depthOrLogDepth, 1.0);
  4886. vec4 eyeCoordinate = czm_windowToEyeCoordinates(windowCoord);
  4887. #endif
  4888. return eyeCoordinate;
  4889. }
  4890. `;var or=`// emulated noperspective
  4891. #if !defined(LOG_DEPTH)
  4892. in float v_WindowZ;
  4893. #endif
  4894. /**
  4895. * Emulates GL_DEPTH_CLAMP. Clamps a fragment to the near and far plane
  4896. * by writing the fragment's depth. See czm_depthClamp for more details.
  4897. *
  4898. * @name czm_writeDepthClamp
  4899. * @glslFunction
  4900. *
  4901. * @example
  4902. * gl_FragColor = color;
  4903. * czm_writeDepthClamp();
  4904. *
  4905. * @see czm_depthClamp
  4906. */
  4907. void czm_writeDepthClamp()
  4908. {
  4909. #if (!defined(LOG_DEPTH) && (__VERSION__ == 300 || defined(GL_EXT_frag_depth)))
  4910. gl_FragDepth = clamp(v_WindowZ * gl_FragCoord.w, 0.0, 1.0);
  4911. #endif
  4912. }
  4913. `;var rr=`// emulated noperspective
  4914. #ifndef LOG_DEPTH
  4915. varying float v_WindowZ;
  4916. #endif
  4917. /**
  4918. * Clamps a vertex to the far plane by writing the fragments depth.
  4919. * <p>
  4920. * The shader must enable the GL_EXT_frag_depth extension.
  4921. * </p>
  4922. *
  4923. * @name czm_writeDepthClampedToFarPlane
  4924. * @glslFunction
  4925. *
  4926. * @example
  4927. * gl_FragColor = color;
  4928. * czm_writeDepthClampedToFarPlane();
  4929. *
  4930. * @see czm_depthClampFarPlane
  4931. */
  4932. void czm_writeDepthClampedToFarPlane()
  4933. {
  4934. #if defined(GL_EXT_frag_depth) && !defined(LOG_DEPTH)
  4935. gl_FragDepthEXT = min(v_WindowZ * gl_FragCoord.w, 1.0);
  4936. #endif
  4937. }
  4938. `;var ir=`// \u5199\u5165\u7EBF\u6027\u6DF1\u5EA6\uFF0C\u53EF\u4EE5\u7406\u89E3\u4E3A\u7269\u4F53\u76F8\u673A\u5750\u6807\u5230\u8FD1\u88C1\u526A\u9762\u7684\u8DDD\u79BB\uFF0C\u5728\u8FDC\u8FD1\u88C1\u526A\u9762\u8303\u56F4\u5185\u5F52\u4E00\u5316\u52300\u52301
  4939. void czm_writeLinearDepth(vec4 positionEC)
  4940. {
  4941. #if (defined(GL_EXT_frag_depth) || defined(WEBGL2)) && defined(LINEAR_DEPTH)
  4942. gl_FragDepthEXT = czm_computeLinearDepth(positionEC);
  4943. #endif
  4944. }
  4945. `;var ar=`#ifdef LOG_DEPTH
  4946. varying float v_depthFromNearPlusOne;
  4947. #ifdef POLYGON_OFFSET
  4948. uniform vec2 u_polygonOffset;
  4949. #endif
  4950. #endif
  4951. /**
  4952. * Writes the fragment depth to the logarithmic depth buffer.
  4953. * <p>
  4954. * Use this when the vertex shader does not call {@link czm_vertexlogDepth}, for example, when
  4955. * ray-casting geometry using a full screen quad.
  4956. * </p>
  4957. * @name czm_writeLogDepth
  4958. * @glslFunction
  4959. *
  4960. * @param {float} depth The depth coordinate, where 1.0 is on the near plane and
  4961. * depth increases in eye-space units from there
  4962. *
  4963. * @example
  4964. * czm_writeLogDepth((czm_projection * v_positionEyeCoordinates).w + 1.0);
  4965. */
  4966. void czm_writeLogDepth(float depth)
  4967. {
  4968. #if (defined(GL_EXT_frag_depth) || defined(WEBGL2)) && defined(LOG_DEPTH)
  4969. // Discard the vertex if it's not between the near and far planes.
  4970. // We allow a bit of epsilon on the near plane comparison because a 1.0
  4971. // from the vertex shader (indicating the vertex should be _on_ the near
  4972. // plane) will not necessarily come here as exactly 1.0.
  4973. if (depth <= 0.9999999 || depth > czm_farDepthFromNearPlusOne) {
  4974. discard;
  4975. }
  4976. #ifdef POLYGON_OFFSET
  4977. // Polygon offset: m * factor + r * units
  4978. float factor = u_polygonOffset[0];
  4979. float units = u_polygonOffset[1];
  4980. // If we can't compute derivatives, just leave out the factor I guess?
  4981. #ifdef GL_OES_standard_derivatives
  4982. // m = sqrt(dZdX^2 + dZdY^2);
  4983. float x = dFdx(depth);
  4984. float y = dFdy(depth);
  4985. float m = sqrt(x * x + y * y);
  4986. // Apply the factor before computing the log depth.
  4987. depth += m * factor;
  4988. #endif
  4989. #endif
  4990. gl_FragDepthEXT = log2(depth) * czm_oneOverLog2FarDepthFromNearPlusOne;
  4991. #ifdef POLYGON_OFFSET
  4992. // Apply the units after the log depth.
  4993. gl_FragDepthEXT += czm_epsilon7 * units;
  4994. #endif
  4995. #endif
  4996. }
  4997. /**
  4998. * Writes the fragment depth to the logarithmic depth buffer.
  4999. * <p>
  5000. * Use this when the vertex shader calls {@link czm_vertexlogDepth}.
  5001. * </p>
  5002. *
  5003. * @name czm_writeLogDepth
  5004. * @glslFunction
  5005. */
  5006. void czm_writeLogDepth() {
  5007. #ifdef LOG_DEPTH
  5008. czm_writeLogDepth(v_depthFromNearPlusOne);
  5009. #endif
  5010. }
  5011. `;var lr=`/**
  5012. * Transforms a value for non-perspective interpolation by multiplying
  5013. * it by w, the value used in the perspective divide. This function is
  5014. * intended to be called in a vertex shader to compute the value of a
  5015. * \`varying\` that should not be subject to perspective interpolation.
  5016. * For example, screen-space texture coordinates. The fragment shader
  5017. * must call {@link czm_readNonPerspective} to retrieve the final
  5018. * non-perspective value.
  5019. *
  5020. * @name czm_writeNonPerspective
  5021. * @glslFunction
  5022. *
  5023. * @param {float|vec2|vec3|vec4} value The value to be interpolated without accounting for perspective.
  5024. * @param {float} w The perspective divide value. Usually this is the computed \`gl_Position.w\`.
  5025. * @returns {float|vec2|vec3|vec4} The transformed value, intended to be stored in a \`varying\` and read in the
  5026. * fragment shader with {@link czm_readNonPerspective}.
  5027. */
  5028. float czm_writeNonPerspective(float value, float w) {
  5029. return value * w;
  5030. }
  5031. vec2 czm_writeNonPerspective(vec2 value, float w) {
  5032. return value * w;
  5033. }
  5034. vec3 czm_writeNonPerspective(vec3 value, float w) {
  5035. return value * w;
  5036. }
  5037. vec4 czm_writeNonPerspective(vec4 value, float w) {
  5038. return value * w;
  5039. }
  5040. `;var cr=`/**
  5041. * Converts a CIE Yxy color to RGB.
  5042. * <p>The conversion is described in
  5043. * </p>
  5044. *
  5045. * @name czm_XYZToRGB
  5046. * @glslFunction
  5047. *
  5048. * @param {vec3} Yxy The color in CIE Yxy.
  5049. *
  5050. * @returns {vec3} The color in RGB.
  5051. *
  5052. * @example
  5053. * vec3 xyz = czm_RGBToXYZ(rgb);
  5054. * xyz.x = max(xyz.x - luminanceThreshold, 0.0);
  5055. * rgb = czm_XYZToRGB(xyz);
  5056. */
  5057. vec3 czm_XYZToRGB(vec3 Yxy)
  5058. {
  5059. const mat3 XYZ2RGB = mat3( 3.2405, -0.9693, 0.0556,
  5060. -1.5371, 1.8760, -0.2040,
  5061. -0.4985, 0.0416, 1.0572);
  5062. vec3 xyz;
  5063. xyz.r = Yxy.r * Yxy.g / Yxy.b;
  5064. xyz.g = Yxy.r;
  5065. xyz.b = Yxy.r * (1.0 - Yxy.g - Yxy.b) / Yxy.b;
  5066. return XYZ2RGB * xyz;
  5067. }
  5068. `;var Re={czm_degreesPerRadian:Cn,czm_depthRange:Tn,czm_ellipsoidInverseRadii:yn,czm_ellipsoidRadii:zn,czm_epsilon1:bn,czm_epsilon2:wn,czm_epsilon3:Ln,czm_epsilon4:Sn,czm_epsilon5:En,czm_epsilon6:An,czm_epsilon7:Dn,czm_infinity:On,czm_oneOverPi:In,czm_oneOverTwoPi:Rn,czm_passCesium3DTile:Mn,czm_passCesium3DTileClassification:Pn,czm_passCesium3DTileClassificationIgnoreShow:Vn,czm_passClassification:Fn,czm_passCompute:Bn,czm_passEnvironment:Nn,czm_passGlobe:Hn,czm_passGround:Un,czm_passOpaque:Gn,czm_passOverlay:kn,czm_passTerrainClassification:Wn,czm_passTranslucent:qn,czm_pi:Xn,czm_piOverFour:Yn,czm_piOverSix:jn,czm_piOverThree:Zn,czm_piOverTwo:Kn,czm_radiansPerDegree:Qn,czm_sceneMode2D:Jn,czm_sceneMode3D:$n,czm_sceneModeColumbusView:et,czm_sceneModeMorphing:nt,czm_solarRadius:tt,czm_threePiOver2:ot,czm_twoPi:rt,czm_webMercatorMaxLatitude:it,czm_depthRangeStruct:at,czm_ellipsoid:lt,czm_material:ct,czm_materialInput:st,czm_ray:ft,czm_raySegment:ut,czm_s3mMaterialInput:mt,czm_shadowParameters:dt,czm_acesTonemapping:pt,czm_adjustColor:vt,czm_alphaWeight:ht,czm_antialias:gt,czm_approximateSphericalCoordinates:_t,czm_branchFreeTernary:xt,czm_cascadeColor:Ct,czm_cascadeDistance:Tt,czm_cascadeMatrix:yt,czm_cascadeWeights:zt,czm_clip:bt,czm_columbusViewMorph:wt,czm_computeLightColorInFP:Lt,czm_computeLightColorInstanceInFP:St,czm_computeLinearDepth:Et,czm_computeNormal:At,czm_computePosition:Dt,czm_cosineAndSine:Ot,czm_decompressTextureCoordinates:It,czm_depthClamp:Rt,czm_depthClampFarPlane:Mt,czm_directionLight:Pt,czm_eastNorthUpToEyeCoordinates:Vt,czm_ellipsoidContainsPoint:Ft,czm_ellipsoidNew:Bt,czm_ellipsoidWgs84TextureCoordinates:Nt,czm_equalsEpsilon:Ht,czm_executeExcavation:Ut,czm_eyeOffset:Gt,czm_eyeToWindowCoordinates:kt,czm_fastApproximateAtan:Wt,czm_floatToRGBA4:qt,czm_fog:Xt,czm_gammaCorrect:Yt,czm_geodeticSurfaceNormal:jt,czm_getDefaultMaterial:Zt,czm_getEmissiveTextureColor:Kt,czm_getHorizontalColor:Qt,czm_getHypsometricColor:Jt,czm_getLambertDiffuse:$t,czm_getSpecular:eo,czm_getTexColorForS3M:no,czm_getTextureMatrixFromZValue:to,czm_getVolumeValue:oo,czm_getVolumeValueMultiResolution:ro,czm_getWaterNoise:io,czm_getWgs84EllipsoidEC:ao,czm_HSBToRGB:lo,czm_HSLToRGB:co,czm_hue:so,czm_inverseGamma:fo,czm_inverseMatrix:uo,czm_isEmpty:mo,czm_isFull:po,czm_latitudeToWebMercatorFraction:vo,czm_lineDistance:ho,czm_luminance:go,czm_metersPerPixel:_o,czm_modelToWindowCoordinates:xo,czm_multiplyWithColorBalance:Co,czm_nearFarScalar:To,czm_octDecode:yo,czm_packDepth:zo,czm_packValue:bo,czm_phong:wo,czm_planeDistance:Lo,czm_pointAlongRay:So,czm_rayEllipsoidIntersectionInterval:Eo,czm_readDepth:Ao,czm_readNonPerspective:Do,czm_reverseLogDepth:Oo,czm_RGBA4ToFloat:Io,czm_RGBToHSB:Ro,czm_RGBToHSL:Mo,czm_RGBToXYZ:Po,czm_RollerShutter:Vo,czm_s3mBatchOperation:Fo,czm_S3MPBR:Bo,czm_sampleAndBlend:No,czm_sampleOctahedralProjection:Ho,czm_saturation:Uo,czm_shadowDepthCompare:Go,czm_shadowVisibility:ko,czm_signNotZero:Wo,czm_sketchMode:qo,czm_sphericalHarmonics:Xo,czm_tangentToEyeSpaceMatrix:Yo,czm_transformPlane:jo,czm_translateRelativeToEye:Zo,czm_translucentPhong:Ko,czm_transpose:Qo,czm_unpackDepth:Jo,czm_unpackFloat:$o,czm_unpackValue:er,czm_vertexLogDepth:nr,czm_windowToEyeCoordinates:tr,czm_writeDepthClamp:or,czm_writeDepthClampedToFarPlane:rr,czm_writeLinearDepth:ir,czm_writeLogDepth:ar,czm_writeNonPerspective:lr,czm_XYZToRGB:cr};var sr=`
  5069. #ifdef HAS_RAIN
  5070. uniform float uAnimationSpeed;
  5071. uniform sampler2D uRippleTexture;
  5072. uniform float uRippleScale;
  5073. uniform float uWindIntensity;
  5074. uniform float uRain;
  5075. uniform float uCameraDepth;
  5076. void getTimeInfo(float animationSpeed, out vec2 timeVec)
  5077. {
  5078. float time = czm_frameNumber * animationSpeed;
  5079. time = floor(30.0 * time);
  5080. float time_diff = floor(time*0.25);
  5081. time = mod(time, 4.0);
  5082. time_diff = mod(time_diff, 4.0);
  5083. timeVec = vec2(time, time_diff);
  5084. }
  5085. void getPosInfo(vec4 posMC, out vec2 posMC_frac1, out vec2 posMC_frac2)
  5086. {
  5087. float ripple_scale = 1.0 / uRippleScale;
  5088. vec2 posXY = posMC.xy * ripple_scale;
  5089. posMC_frac1 = fract(posXY);
  5090. vec2 posStep = vec2(0.5);
  5091. posMC_frac2 = fract(posXY + posStep);
  5092. }
  5093. float getAlpha(vec2 posMC_frac1)
  5094. {
  5095. vec2 dist = (posMC_frac1 - vec2(0.5)) * 2.0;
  5096. dist = vec2(abs(dist.x), abs(dist.y));
  5097. vec2 result = pow(dist, vec2(5.0));
  5098. return result.x + result.y;
  5099. }
  5100. vec4 getRippleValue(sampler2D uRippleTexture, vec2 timeVec, vec2 posMC_frac1, vec2 posMC_frac2, float alpha)
  5101. {
  5102. vec2 rippleUV_1 = (timeVec + posMC_frac1)*0.25;
  5103. vec2 rippleUV_2 = (timeVec + posMC_frac2)*0.25;
  5104. vec4 rippleValue_1 = texture2D(uRippleTexture, rippleUV_1.xy);
  5105. vec4 rippleValue_2 = texture2D(uRippleTexture, rippleUV_2.xy);
  5106. return mix(rippleValue_1, rippleValue_2, alpha);
  5107. }
  5108. vec3 getRippleNormal(vec4 rippleValue, float wind_intensity, float rain, float depthFade)
  5109. {
  5110. vec2 rippleValueXY = rippleValue.xy;
  5111. vec2 rippleValueZW = rippleValue.zw;
  5112. const vec2 _value = vec2(0.5);
  5113. vec2 part_1 = (rippleValueZW - _value) * wind_intensity * 0.13;
  5114. vec2 part_2 = (rippleValueXY - _value) * 0.6;
  5115. vec2 mergedValue = mix(part_1, part_2, rain) * depthFade;
  5116. return vec3(mergedValue, 1.0);
  5117. }
  5118. float getNormalAlpha(vec3 normalWS,float wetness)
  5119. {
  5120. float valueZ = normalWS.z - 0.5;
  5121. float wet_correction = wetness * clamp(valueZ * 2.5, 0.0, 1.0);
  5122. return pow(wet_correction, 15.0);
  5123. }
  5124. vec3 rippleNormalCorrection(vec3 rippleNormal,float normalAlpha)
  5125. {
  5126. const vec3 blueNormal = vec3(0.0, 0.0, 1.0);
  5127. return mix(blueNormal, rippleNormal, normalAlpha);
  5128. }
  5129. vec3 rippleGenerator(sampler2D uRippleTexture, float animationSpeed,vec3 normalWS,float wetness)
  5130. {
  5131. vec2 timeVec = vec2(1.0);
  5132. getTimeInfo(animationSpeed, timeVec);
  5133. vec2 posMC_frac1 = vec2(1.0);
  5134. vec2 posMC_frac2 = vec2(1.0);
  5135. getPosInfo(vPositionMC, posMC_frac1, posMC_frac2);
  5136. float alpha = getAlpha(posMC_frac1);
  5137. vec4 rippleValue = getRippleValue(uRippleTexture, timeVec, posMC_frac1, posMC_frac2, alpha);
  5138. vec3 rippleNormal = getRippleNormal(rippleValue, uWindIntensity, uRain, uCameraDepth);
  5139. float normalAlpha = getNormalAlpha(normalWS, wetness);
  5140. return normalize(rippleNormalCorrection(rippleNormal, normalAlpha));
  5141. }
  5142. #endif
  5143. `;var fr=`
  5144. #ifdef HAS_SNOW
  5145. uniform float uSnowCoverageFactor;
  5146. uniform sampler2D uSnowMaskTexture;
  5147. uniform sampler2D uSnowNormalTexture;
  5148. vec3 getSnowMaskValue(sampler2D uSnowMaskTexture, vec2 snowUV)
  5149. {
  5150. return texture2D(uSnowMaskTexture, snowUV).rgb;
  5151. }
  5152. float getSnowCoverage(float snow_coverage, float max_snow_coverage, vec3 normalWS, float z_mask)
  5153. {
  5154. float normal_z = normalWS.z;
  5155. normal_z += 1.1 + z_mask;
  5156. normal_z = clamp(normal_z * 0.5, 0.0, 1.0);
  5157. float final_snow_coverage = clamp(snow_coverage, 0.0, max_snow_coverage);
  5158. final_snow_coverage = clamp(final_snow_coverage*normal_z, 0.0, 1.0);
  5159. return final_snow_coverage;
  5160. }
  5161. float getSnowCoverageWithMaskTexture(float finalSnowCoverage, float heightValue, float snow_scatter_value, float snow_scatter_alpha, float tighten_value)
  5162. {
  5163. float scatter_value = mix(heightValue, snow_scatter_value, snow_scatter_alpha);
  5164. return clamp((tighten_value + 1.0) * finalSnowCoverage - tighten_value * scatter_value, 0.0, 1.0);
  5165. }
  5166. float getSnowAlpha(vec3 normalWS, float snow_coverage, float z_mask)
  5167. {
  5168. return clamp((normalWS.z + z_mask) * 5.0, 0.0, 1.0) * snow_coverage;
  5169. }
  5170. vec3 getFinalBaseColor(vec3 baseColor, vec3 snow_baseColor, float snowAlpha)
  5171. {
  5172. return mix(baseColor, snow_baseColor, snowAlpha);
  5173. }
  5174. float getFinalRoughness(float roughness, float snow_roughness, float snowAlpha)
  5175. {
  5176. return mix(roughness, snow_roughness, snowAlpha);
  5177. }
  5178. vec3 getFinalNormal(vec3 normalWS, vec3 snowNormal, float blendNormalValue, float snow_coverage)
  5179. {
  5180. vec3 snowNormal_part2 = vec3(snowNormal.xy - vec2(0.5), 1.0);
  5181. float normal_alpha = (1.0 - blendNormalValue)* snow_coverage;
  5182. return mix(normalWS, snowNormal_part2, normal_alpha);
  5183. }
  5184. void snowGenerator(sampler2D uSnowMaskTexture, sampler2D uSnowNormalTexture, vec2 snowUV, float snow_coverage, inout vec3 normalWS, inout vec3 baseColor, inout float roughness)
  5185. {
  5186. vec3 snowMaskValue = texture2D(uSnowMaskTexture, snowUV).rgb;
  5187. const float max_snow_coverage = 1.0;
  5188. const float z_mask = 0.0;
  5189. float snowCoverage = getSnowCoverage(snow_coverage, max_snow_coverage, normalWS, z_mask);
  5190. const float heightValue = 0.5;
  5191. float snow_scatter_value = snowMaskValue.g;
  5192. const float snow_scatter_alpha = 0.5;
  5193. const float tighten_value = 4.0;
  5194. snowCoverage = getSnowCoverageWithMaskTexture(snowCoverage, heightValue, snow_scatter_value, snow_scatter_alpha, tighten_value);
  5195. float snow_alpha = getSnowAlpha(normalWS, snowCoverage, z_mask);
  5196. baseColor = getFinalBaseColor(baseColor, vec3(snowMaskValue.r), snow_alpha);
  5197. roughness = getFinalRoughness(roughness, snowMaskValue.b, snow_alpha);
  5198. vec3 snowNormalValue = texture2D(uSnowNormalTexture, snowUV).rgb;
  5199. const float blendNormalValue = 0.3;
  5200. normalWS = getFinalNormal(normalWS, snowNormalValue, blendNormalValue, snowCoverage);
  5201. }
  5202. #endif
  5203. `;var ur=`
  5204. #ifdef HAS_HEMISPHERE_LIGHTS
  5205. uniform vec3 uSkyColor[ HEMISPHERE_LIGHTS ];
  5206. uniform vec3 uGroundColor[ HEMISPHERE_LIGHTS ];
  5207. uniform vec3 uHemisphereLightDirectionEC[ HEMISPHERE_LIGHTS ];
  5208. struct HemisphereLight {
  5209. vec3 direction;
  5210. vec3 skyColor;
  5211. vec3 groundColor;
  5212. };
  5213. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {
  5214. float dotNL = dot( geometry.normal, hemiLight.direction );
  5215. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  5216. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  5217. return irradiance;
  5218. }
  5219. #endif
  5220. `;var mr=`
  5221. #ifdef HAS_POINT_LIGHTS
  5222. uniform vec3 uPointLightPositionEC[ POINT_LIGHTS ];
  5223. uniform vec3 uPointLightColor[ POINT_LIGHTS ];
  5224. uniform vec2 uPointLightDistanceAndDecay[ POINT_LIGHTS ];
  5225. struct PointLight {
  5226. vec3 position;
  5227. vec3 color;
  5228. float distance;
  5229. float decay;
  5230. };
  5231. void getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {
  5232. vec3 lVector = pointLight.position - geometry.position;
  5233. directLight.direction = normalize( lVector );
  5234. float lightDistance = length( lVector );
  5235. directLight.color = pointLight.color;
  5236. directLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );
  5237. directLight.visible = ( directLight.color != vec3( 0.0 ) );
  5238. }
  5239. #endif
  5240. `;var dr=`
  5241. #ifdef HAS_SPOT_LIGHTS
  5242. uniform vec3 uSpotLightColor[ SPOT_LIGHTS ];
  5243. uniform vec3 uSpotLightPositionEC[ SPOT_LIGHTS ];
  5244. uniform vec3 uSpotLightDirectionEC[ SPOT_LIGHTS ];
  5245. uniform vec4 uSpotLightDistanceDecayCosPenumbra[ SPOT_LIGHTS ];
  5246. uniform vec3 uSpotLightExponent[ SPOT_LIGHTS ];
  5247. struct SpotLight {
  5248. vec3 position;
  5249. vec3 direction;
  5250. vec3 color;
  5251. float distance;
  5252. float decay;
  5253. float coneCos;
  5254. float penumbraCos;
  5255. };
  5256. void getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {
  5257. vec3 lVector = spotLight.position - geometry.position;
  5258. directLight.direction = normalize( lVector );
  5259. float lightDistance = length( lVector );
  5260. float angleCos = dot( directLight.direction, spotLight.direction );
  5261. if ( angleCos > spotLight.coneCos ) {
  5262. float spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  5263. directLight.color = spotLight.color;
  5264. directLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );
  5265. directLight.visible = true;
  5266. } else {
  5267. directLight.color = vec3( 0.0 );
  5268. directLight.visible = false;
  5269. }
  5270. }
  5271. #endif
  5272. `;var pr=`
  5273. #ifdef HAS_DIR_LIGHTS
  5274. uniform vec3 uDirectionalLightDirectionEC[ DIR_LIGHTS ];
  5275. uniform vec3 uDirectionalLightColor[ DIR_LIGHTS ];
  5276. #endif
  5277. `;var vr=`
  5278. #ifdef HAS_DIR_LIGHTS
  5279. for (int i = 0; i < DIR_LIGHTS; i++) {
  5280. directLight.color = uDirectionalLightColor[i];
  5281. directLight.direction = uDirectionalLightDirectionEC[i];
  5282. directLight.visible = true;
  5283. directPhysical( directLight, geometry, material, reflectedLight );
  5284. }
  5285. #endif
  5286. #ifdef HAS_POINT_LIGHTS
  5287. PointLight pointLight;
  5288. for (int i = 0; i < POINT_LIGHTS; i++) {
  5289. pointLight.position = uPointLightPositionEC[i];
  5290. pointLight.color = uPointLightColor[i];
  5291. pointLight.distance = uPointLightDistanceAndDecay[i].x;
  5292. pointLight.decay = uPointLightDistanceAndDecay[i].y;
  5293. getPointDirectLightIrradiance( pointLight, geometry, directLight );
  5294. if(!directLight.visible) continue;
  5295. directPhysical( directLight, geometry, material, reflectedLight );
  5296. }
  5297. #endif
  5298. #ifdef HAS_SPOT_LIGHTS
  5299. SpotLight spotLight;
  5300. for (int i = 0; i < SPOT_LIGHTS; i++) {
  5301. spotLight.position = uSpotLightPositionEC[i];
  5302. spotLight.color = uSpotLightColor[i];
  5303. spotLight.direction = uSpotLightDirectionEC[i];
  5304. spotLight.coneCos = uSpotLightDistanceDecayCosPenumbra[i].z;
  5305. spotLight.penumbraCos = uSpotLightDistanceDecayCosPenumbra[i].w;
  5306. getSpotDirectLightIrradiance( spotLight, geometry, directLight );
  5307. if(!directLight.visible) continue;
  5308. directPhysical( directLight, geometry, material, reflectedLight );
  5309. }
  5310. #endif
  5311. `;var hr=`
  5312. #ifdef BRDF
  5313. #define RECIPROCAL_PI 0.31830988618
  5314. #define M_PI 3.141592653589793
  5315. #define EPSILON 1e-6
  5316. #define CUBEUV_MAX_MIP 8.0
  5317. #define CUBEUV_TEXEL_WIDTH 0.0013020833333333333
  5318. #define CUBEUV_TEXEL_HEIGHT 0.0009765625
  5319. #define saturate(a) clamp( a, 0.0, 1.0 )
  5320. float pow2( const in float x ) { return x * x; }
  5321. uniform vec4 uBaseColorFactor;
  5322. uniform vec4 uEmissiveFactor;
  5323. uniform float uMetallicFactor;
  5324. uniform float uRoughnessFactor;
  5325. uniform float uAlphaCutoff;
  5326. uniform float uEnvMapIntensity;
  5327. uniform float uCameraReflect;
  5328. struct IncidentLight {
  5329. vec3 direction;
  5330. vec3 color;
  5331. bool visible;
  5332. };
  5333. struct GeometricContext {
  5334. vec3 position;
  5335. vec3 normal;
  5336. vec3 viewDir;
  5337. };
  5338. struct PhysicalMaterial {
  5339. vec3 diffuseColor;
  5340. float roughness;
  5341. vec3 specularColor;
  5342. float specularF90;
  5343. };
  5344. struct ReflectedLight {
  5345. vec3 directDiffuse;
  5346. vec3 directSpecular;
  5347. vec3 indirectDiffuse;
  5348. vec3 indirectSpecular;
  5349. };
  5350. #ifdef HAS_BASE_TEXTURE
  5351. uniform sampler2D uBaseTexture;
  5352. #endif
  5353. #ifdef HAS_NORMAL_TEXTURE
  5354. uniform sampler2D uNormalTexture;
  5355. uniform float uNormalTextureScale;
  5356. #ifdef HAS_ANISOTROPY
  5357. uniform vec4 uAnisotropy;
  5358. #endif
  5359. #endif
  5360. #ifdef HAS_EMISSIVE_TEXTURE
  5361. uniform sampler2D uEmissionTexture;
  5362. uniform vec4 uEmissiveUVOffsetAndTiling;
  5363. #endif
  5364. #ifdef HAS_MetallicRoughness_TEXTURE
  5365. uniform sampler2D uMetallicRoughnessTexture;
  5366. #endif
  5367. #ifdef HAS_OCCLUSION_TEXTURE
  5368. uniform sampler2D uOcclusionTexture;
  5369. #endif
  5370. #ifdef REFRACTION
  5371. uniform float uIndexOfRefraction;
  5372. #endif
  5373. #ifdef HAS_TRANSMISSION
  5374. uniform float uTransmissionFactor;
  5375. #endif
  5376. #ifdef HAS_WETNESS
  5377. uniform float uWetnessFactor;
  5378. #endif
  5379. #ifdef HAS_VOLUME
  5380. uniform vec4 uTintColor;
  5381. uniform vec4 uDiffusionDistance;
  5382. uniform float uThickness;
  5383. #endif
  5384. #ifdef HAS_CLEARCOAT
  5385. uniform float uClearcoatFactor;
  5386. uniform float uClearcoatRoughnessFactor;
  5387. #endif
  5388. //\u53C2\u8003UE4.24\u5B9E\u73B0\u8BA1\u7B97\u7CBE\u786E\u5149\u6E90\u7684\u8870\u51CF
  5389. float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  5390. // float d = lightDistance;
  5391. // float r = cutoffDistance;
  5392. // float d2 = d * d;
  5393. // float attenuation = 1.0 / (d2 + 1.0);
  5394. // float m = saturate(1.0 - pow(d / r, 4.0));
  5395. // float m2 = m * m;
  5396. // return attenuation * m2;
  5397. if ( decayExponent > 0.0 ) {
  5398. return pow( saturate( 1.0 - lightDistance / cutoffDistance ), decayExponent );
  5399. }
  5400. return 1.0;
  5401. }
  5402. #include <hemisphereLightDecl>
  5403. #include <directionLightDecl>
  5404. #include <pointLightDecl>
  5405. #include <spotLightDecl>
  5406. #include <snowDecl>
  5407. #include <rainDecl>
  5408. #ifdef HAS_ANISOTROPY
  5409. vec3 getAnisotropicBentNormals(const vec3 T, const vec3 B, const vec3 N, const vec3 V, float anisotropy) {
  5410. vec3 anisotropicFrameDirection = anisotropy >= 0.0 ? B : T;
  5411. vec3 anisotropicFrameTangent = cross(normalize(anisotropicFrameDirection), V);
  5412. vec3 anisotropicFrameNormal = cross(anisotropicFrameTangent, anisotropicFrameDirection);
  5413. vec3 anisotropicNormal = normalize(mix(N, anisotropicFrameNormal, abs(anisotropy)));
  5414. return anisotropicNormal;
  5415. }
  5416. #endif
  5417. #ifdef HAS_VOLUME
  5418. vec3 computeColorAtDistanceInMedia(vec3 color, float distance) {
  5419. return -log(color) / distance;
  5420. }
  5421. vec3 cocaLambert(vec3 alpha, float distance) {
  5422. return exp(-alpha * distance);
  5423. }
  5424. #endif
  5425. vec3 sRGBToLinear(vec3 srgbIn)
  5426. {
  5427. return pow(srgbIn, vec3(2.2));
  5428. }
  5429. vec4 sRGBToLinear(vec4 srgbIn)
  5430. {
  5431. srgbIn = srgbIn ;
  5432. vec3 linearOut = pow(srgbIn.rgb, vec3(2.2));
  5433. return vec4(linearOut, srgbIn.a);
  5434. }
  5435. vec3 LinearTosRGB(vec3 linearIn)
  5436. {
  5437. #ifndef HDR
  5438. return pow(linearIn, vec3(1.0/2.2));
  5439. #else
  5440. return linearIn;
  5441. #endif
  5442. }
  5443. vec3 lambertianDiffuse(vec3 diffuseColor)
  5444. {
  5445. return diffuseColor * RECIPROCAL_PI;
  5446. }
  5447. vec3 applyTonemapping(vec3 linearIn)
  5448. {
  5449. vec3 color = linearIn * czm_toneMappingExposure;
  5450. return czm_acesTonemapping(color);
  5451. }
  5452. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  5453. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  5454. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  5455. }
  5456. float GeometrySchlickGGX(float roughness, float NoV)
  5457. {
  5458. float k = pow(roughness + 1.0, 2.0) / 8.0;
  5459. return NoV / (NoV * (1.0 - k) + k);
  5460. }
  5461. float D_GGX( const in float alpha, const in float dotNH ) {
  5462. float a2 = pow2( alpha );
  5463. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  5464. return RECIPROCAL_PI * a2 / pow2( denom );
  5465. }
  5466. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {
  5467. float alpha = roughness * roughness;
  5468. vec3 halfDir = normalize( lightDir + viewDir );
  5469. float dotNL = clamp( dot( normal, lightDir ), 0.001, 1.0 );
  5470. float dotNV = abs( dot( normal, viewDir ) ) + 0.001;
  5471. float dotNH = saturate( dot( normal, halfDir ) );
  5472. float dotLH = saturate( dot( lightDir, halfDir ) );
  5473. float dotVH = saturate( dot( viewDir, halfDir ) );
  5474. vec3 F = F_Schlick( f0, f90, dotVH );
  5475. float G = GeometrySchlickGGX(alpha, dotNV) * GeometrySchlickGGX(alpha, dotNL);
  5476. float D = D_GGX( alpha, dotNH );
  5477. return F * ( G * D ) / (4.0 * dotNL * dotNV);
  5478. }
  5479. void directPhysical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  5480. float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
  5481. vec3 irradiance = dotNL * directLight.color;
  5482. reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );
  5483. reflectedLight.directDiffuse += irradiance * lambertianDiffuse( material.diffuseColor );
  5484. }
  5485. #ifdef HAS_NORMAL_TEXTURE
  5486. vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec2 uv, vec3 mapN) {
  5487. float fNormalLength = length(mapN);
  5488. if(fNormalLength < 0.5) {
  5489. return surf_norm;
  5490. }
  5491. mapN = mapN * 2.0 - 1.0;
  5492. vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );
  5493. vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );
  5494. vec2 st0 = dFdx( uv.st );
  5495. vec2 st1 = dFdy( uv.st );
  5496. float scale = sign( st1.t * st0.s - st0.t * st1.s );
  5497. vec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );
  5498. vec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );
  5499. vec3 N = normalize( surf_norm );
  5500. mat3 tsn = mat3( S, T, N );
  5501. mapN.xy *= uNormalTextureScale;
  5502. mapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );
  5503. return normalize( tsn * mapN );
  5504. }
  5505. #endif
  5506. #include <cubeUV_reflection>
  5507. vec3 inverseTransformDirection( in vec3 dir ) {
  5508. mat3 fixedToENU = mat3(czm_modelView[0][0], czm_modelView[1][0], czm_modelView[2][0], czm_modelView[0][1], czm_modelView[1][1], czm_modelView[2][1], czm_modelView[0][2], czm_modelView[1][2], czm_modelView[2][2]);
  5509. const mat3 yUpToZUp = mat3(1.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0);
  5510. return normalize( yUpToZUp * fixedToENU * dir );
  5511. }
  5512. void indirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  5513. reflectedLight.indirectDiffuse += irradiance * lambertianDiffuse( material.diffuseColor );
  5514. }
  5515. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  5516. float dotNV = saturate( dot( normal, viewDir ) );
  5517. const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
  5518. const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
  5519. vec4 r = roughness * c0 + c1;
  5520. float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
  5521. vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
  5522. return fab;
  5523. }
  5524. void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
  5525. vec2 fab = DFGApprox( normal, viewDir, roughness );
  5526. vec3 Fr = specularColor;
  5527. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  5528. float Ess = fab.x + fab.y;
  5529. float Ems = 1.0 - Ess;
  5530. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;
  5531. vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  5532. singleScatter += FssEss;
  5533. multiScatter += Fms * Ems;
  5534. }
  5535. void indirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  5536. vec3 singleScattering = vec3( 0.0 );
  5537. vec3 multiScattering = vec3( 0.0 );
  5538. vec3 cosineWeightedIrradiance = irradiance;
  5539. computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  5540. vec3 totalScattering = singleScattering + multiScattering;
  5541. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  5542. reflectedLight.indirectSpecular += radiance * singleScattering;
  5543. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  5544. reflectedLight.indirectSpecular = (uCameraReflect * 0.5 + 0.5) * reflectedLight.indirectSpecular; // \u7C97\u7CD9\u5EA6\u503C\u504F\u5C0F\u4F7F\u8BA1\u7B97\u51FA\u7684\u73AF\u5883\u56FE\u9AD8\u5149\u503C\u504F\u5927\u5BFC\u81F4\u6C34\u9762\u53CD\u5C04\u7684\u6A21\u578B\u6CDB\u767D,\u6545\u6C34\u9762\u53CD\u5C04\u65F6\u4E0D\u8BA1\u7B97\u73AF\u5883\u56FE\u7684\u9AD8\u5149
  5545. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  5546. }
  5547. vec3 getIBLIrradiance( const in vec3 normal ) {
  5548. vec3 worldNormal = inverseTransformDirection( normal );
  5549. vec4 envMapColor = textureCubeUV( czm_hdrEnvMap, worldNormal, 1.0 );
  5550. return envMapColor.rgb;
  5551. }
  5552. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  5553. vec3 reflectVec = reflect( - viewDir, normal );
  5554. reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
  5555. reflectVec = inverseTransformDirection( reflectVec );
  5556. vec4 envMapColor = textureCubeUV( czm_hdrEnvMap, reflectVec, roughness );
  5557. return envMapColor.rgb;
  5558. }
  5559. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  5560. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  5561. }
  5562. uniform float uPbrParTextureWidth;
  5563. void calculateMipLevel(in vec2 inTexCoord, in vec2 vecTile, in float fMaxMip, inout float mipLevel)
  5564. {
  5565. vec2 dx = dFdx(inTexCoord * vecTile.x);
  5566. vec2 dy = dFdy(inTexCoord * vecTile.y);
  5567. float dotX = dot(dx, dx);
  5568. float dotY = dot(dy, dy);
  5569. float dMax = max(dotX, dotY);
  5570. float dMin = min(dotX, dotY);
  5571. float offset = (dMax - dMin) / (dMax + dMin);
  5572. offset = clamp(offset, 0.0, 1.0);
  5573. float d = dMax * (1.0 - offset) + dMin * offset;
  5574. mipLevel = 0.5 * log2(d);
  5575. mipLevel = clamp(mipLevel, 0.0, fMaxMip - 1.62);
  5576. }
  5577. vec3 getTexcoordAndMipmapLevel(vec2 uv, vec4 texMatrix, float texCoordZ) {
  5578. vec2 translate = texMatrix.xy;
  5579. float textureWidth = texMatrix.z * uPbrParTextureWidth;
  5580. float scale = texMatrix.z;
  5581. float maxMipmapLevel = texMatrix.w;
  5582. float mipLevel = 0.0;
  5583. calculateMipLevel(uv, vec2(textureWidth), maxMipmapLevel, mipLevel);
  5584. vec2 texCoord;
  5585. if(texCoordZ < -9000.0)
  5586. {
  5587. texCoord = vec2(uv.x, uv.y);
  5588. }
  5589. else
  5590. {
  5591. texCoord = fract(uv);
  5592. float offset = pow(2.0, mipLevel) / textureWidth;
  5593. texCoord = clamp(texCoord, offset, 1.0 - offset);
  5594. texCoord.x = (texCoord.x + translate.x) * scale;
  5595. texCoord.y = (texCoord.y + translate.y) * scale;
  5596. }
  5597. return vec3(texCoord.xy, mipLevel);
  5598. }
  5599. vec4 brdf(in vec4 baseColorWithAlpha, vec2 texCoord, vec2 oriTexCoord, vec3 posEC, vec3 posMC, vec3 vertexNormalEC, vec4 sunLightColor, float sunLightON) {
  5600. vec2 uv = oriTexCoord;
  5601. float mipmapLevel = 0.0;
  5602. #ifdef USE_BatchPBR
  5603. vec3 uvAndMiplevel = getTexcoordAndMipmapLevel(oriTexCoord, vTexMatrix, vTexCoordZ.x);
  5604. uv = uvAndMiplevel.xy;
  5605. mipmapLevel = uvAndMiplevel.z;
  5606. #endif
  5607. baseColorWithAlpha = baseColorWithAlpha * uBaseColorFactor;
  5608. #ifdef BaseColorReplace
  5609. baseColorWithAlpha = uBaseColorFactor;
  5610. #endif
  5611. //float faceDirection = (gl_FrontFacing ? 1.0 : - 1.0) * uCameraReflect;
  5612. vec3 ng = normalize(vertexNormalEC);
  5613. #ifndef HAS_NORMAL
  5614. ng = normalize(czm_normal * czm_computeNormal(posMC.xyz));
  5615. #else
  5616. float faceDirection = (dot(ng, -normalize(posEC)) < 0.0 ? -1.0 : 1.0) * uCameraReflect;
  5617. ng = ng * faceDirection;
  5618. #endif
  5619. #ifdef HAS_BASE_TEXTURE
  5620. #ifdef USE_BatchPBR
  5621. baseColorWithAlpha *= sRGBToLinear(texture2DLodEXT(uBaseTexture, uv * uTexUVOffset.zw + uTexUVOffset.xy, mipmapLevel));
  5622. #else
  5623. baseColorWithAlpha = sRGBToLinear(texture2D(uBaseTexture, oriTexCoord * uTexUVOffset.zw + uTexUVOffset.xy)) * uBaseColorFactor * vColor;
  5624. #endif
  5625. #endif
  5626. #ifdef HAS_NORMAL_TEXTURE
  5627. #ifdef USE_BatchPBR
  5628. vec3 mapN = texture2DLodEXT( uNormalTexture, uv, mipmapLevel).xyz;
  5629. #else
  5630. vec3 mapN = texture2D( uNormalTexture, uv).xyz;
  5631. #endif
  5632. vec3 n = perturbNormal2Arb(posEC, ng, oriTexCoord, mapN);
  5633. #ifdef HAS_ANISOTROPY
  5634. float anisotropy = uAnisotropy.b;
  5635. vec3 anisotropyDirection = vec3(uAnisotropy.xy, 0.0);
  5636. vec3 anisotropicTangent = normalize(tbn * anisotropyDirection);
  5637. vec3 anisotropicBitangent = normalize(cross(tbn[2], anisotropicTangent));
  5638. n = getAnisotropicBentNormals(anisotropicTangent, anisotropicBitangent, n, v, anisotropy);
  5639. #endif
  5640. #else
  5641. vec3 n = ng;
  5642. #endif
  5643. #ifdef HAS_WETNESS
  5644. mat3 fixedToENU_wetness = mat3(czm_modelView[0][0], czm_modelView[1][0], czm_modelView[2][0], czm_modelView[0][1], czm_modelView[1][1], czm_modelView[2][1], czm_modelView[0][2], czm_modelView[1][2], czm_modelView[2][2]);
  5645. vec3 normalWS_wetness = normalize(fixedToENU_wetness * n);
  5646. #endif
  5647. #ifdef HAS_RAIN
  5648. n = rippleGenerator(uRippleTexture,uAnimationSpeed,normalWS_wetness,uWetnessFactor);
  5649. #endif
  5650. vec3 baseColor = baseColorWithAlpha.rgb;
  5651. float roughness = uRoughnessFactor;
  5652. float metalness = uMetallicFactor;
  5653. vec4 emissiveFactor = uEmissiveFactor;
  5654. vec2 emissiveTexCoord = texCoord.xy;
  5655. #ifdef PBR_THEME
  5656. int pbrIndex = int(vPBRIndex);
  5657. if(vPBRIndex < 0.0)
  5658. {
  5659. return baseColorWithAlpha;
  5660. }
  5661. mat4 pbrPar = mat4(0.0);
  5662. for(int i = 0;i < NUM_PBR_MATERIALS;i++)
  5663. {
  5664. if(i == pbrIndex)
  5665. {
  5666. pbrPar = uPBRMaterials[i];
  5667. break;
  5668. }
  5669. }
  5670. roughness = clamp(pbrPar[0][0], 0.04, 1.0);
  5671. metalness = clamp(pbrPar[0][1], 0.0, 1.0);
  5672. baseColor = (baseColorWithAlpha / uBaseColorFactor * vec4(pbrPar[0][2], pbrPar[0][3], pbrPar[1][0], pbrPar[1][1])).rgb;
  5673. #endif
  5674. #ifdef USE_BatchPBR
  5675. metalness = vMetallicRoughness.x;
  5676. roughness = vMetallicRoughness.y;
  5677. emissiveFactor = vEmissiveFactor;
  5678. emissiveTexCoord = texCoord.xy;
  5679. #endif
  5680. metalness = clamp(metalness, 0.0, 1.0);
  5681. roughness = clamp(roughness, 0.0, 1.0);
  5682. #ifdef HAS_MetallicRoughness_TEXTURE
  5683. #ifdef USE_BatchPBR
  5684. vec3 metallicRoughness = texture2DLodEXT(uMetallicRoughnessTexture, uv, mipmapLevel).rgb;
  5685. #else
  5686. vec3 metallicRoughness = texture2D(uMetallicRoughnessTexture, oriTexCoord).rgb;
  5687. #endif
  5688. metalness = clamp(metalness * metallicRoughness.r, 0.0, 1.0);
  5689. roughness = clamp(roughness * metallicRoughness.g, 0.04, 1.0);
  5690. #ifdef HAS_WETNESS
  5691. float fWetness = clamp(uWetnessFactor,0.0,1.0);
  5692. float fWetness_correction = pow(4.0*fWetness,2.0);
  5693. fWetness_correction = clamp(fWetness_correction,clamp(fWetness,0.0,0.9),1.0);
  5694. float fWerness_normalized = fWetness_correction * clamp(normalWS_wetness.z + 0.85,0.0,1.0);
  5695. baseColor = mix(baseColor,baseColor*0.7,fWerness_normalized);
  5696. roughness = mix(roughness,0.05,fWerness_normalized);
  5697. #endif
  5698. #ifdef HAS_SNOW
  5699. mat3 fixedToENU_snow = mat3(czm_modelView[0][0], czm_modelView[1][0], czm_modelView[2][0], czm_modelView[0][1], czm_modelView[1][1], czm_modelView[2][1], czm_modelView[0][2], czm_modelView[1][2], czm_modelView[2][2]);
  5700. vec3 normalWS_snow = normalize(fixedToENU_snow * n);
  5701. snowGenerator(uSnowMaskTexture,uSnowNormalTexture, oriTexCoord,uSnowCoverageFactor,normalWS_snow,baseColor,roughness);
  5702. #endif
  5703. #endif
  5704. vec3 lightColorHdr = vec3(2.0) * uSunLightON; // \u592A\u9633\u5149
  5705. vec3 l = normalize(czm_lightDirectionEC);
  5706. vec3 v = -normalize(posEC);
  5707. vec3 h = normalize(v + l);
  5708. vec3 f0 = vec3(0.04);
  5709. vec3 diffuseColor = baseColor * (1.0 - metalness) * (1.0 - f0);
  5710. vec3 specularColor = mix(f0, baseColor, metalness);
  5711. float alpha = roughness * roughness;
  5712. float dotNL = clamp( dot( n, l ), 0.001, 1.0 );
  5713. float dotNV = abs( dot( n, v ) ) + 0.001;
  5714. float dotNH = saturate( dot( n, h ) );
  5715. float dotLH = saturate( dot( l, h ) );
  5716. float dotVH = saturate( dot( v, h ) );
  5717. float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);
  5718. float f90 = clamp(reflectance * 25.0, 0.0, 1.0);
  5719. vec3 F = F_Schlick( specularColor, f90, dotVH );
  5720. float G = GeometrySchlickGGX(alpha, dotNV) * GeometrySchlickGGX(alpha, dotNL);
  5721. float D = D_GGX( alpha, dotNH );
  5722. vec3 diffuseContribution = (1.0 - F) * lambertianDiffuse(diffuseColor);
  5723. vec3 specularContribution = F * G * D / (4.0 * dotNL * dotNV);
  5724. vec3 geometryNormal = ng;
  5725. PhysicalMaterial material;
  5726. material.diffuseColor = diffuseColor;
  5727. vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );
  5728. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  5729. material.roughness = max( roughness, 0.0525 );
  5730. material.roughness += geometryRoughness;
  5731. material.roughness = min( material.roughness, 1.0 );
  5732. material.specularColor = specularColor;
  5733. material.specularF90 = 1.0;
  5734. GeometricContext geometry;
  5735. geometry.position = posEC;
  5736. geometry.normal = n;
  5737. geometry.viewDir = v;
  5738. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  5739. reflectedLight.directDiffuse += dotNL * lightColorHdr * diffuseContribution;
  5740. reflectedLight.directSpecular += dotNL * lightColorHdr * specularContribution;
  5741. IncidentLight directLight;
  5742. #include <lightSourceImpl>
  5743. vec3 irradiance = vec3(0.0);
  5744. vec3 radiance = vec3(0.0);
  5745. #ifdef HAS_HEMISPHERE_LIGHTS
  5746. HemisphereLight hemiLight;
  5747. hemiLight.skyColor = uSkyColor[0];
  5748. hemiLight.groundColor = uGroundColor[0];
  5749. hemiLight.direction = normalize(czm_normal * vec3(0.0, 0.0, 1.0));
  5750. irradiance += getHemisphereLightIrradiance( hemiLight, geometry );
  5751. #endif
  5752. #ifdef IBL
  5753. #ifdef KtxEnvMap
  5754. mat3 fixedToENU = mat3(czm_modelView[0][0], czm_modelView[1][0], czm_modelView[2][0], czm_modelView[0][1], czm_modelView[1][1], czm_modelView[2][1], czm_modelView[0][2], czm_modelView[1][2], czm_modelView[2][2]);
  5755. const mat3 yUpToZUp = mat3(-1.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0);
  5756. vec3 cubeDir = normalize( yUpToZUp * fixedToENU * reflect(-v, n) );
  5757. vec3 worldNormal = normalize( yUpToZUp * fixedToENU * n );
  5758. irradiance += czm_sphericalHarmonics(worldNormal, czm_sphericalHarmonicCoefficients);
  5759. radiance += czm_sampleOctahedralProjection(czm_specularEnvironmentMaps, czm_specularEnvironmentMapSize, cubeDir, roughness * czm_specularEnvironmentMapsMaximumLOD, czm_specularEnvironmentMapsMaximumLOD);
  5760. #else
  5761. irradiance += getIBLIrradiance( geometry.normal );
  5762. radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );
  5763. #endif
  5764. #else
  5765. vec3 positionWC = vec3(czm_inverseView * vec4(posEC, 1.0));
  5766. vec3 r = normalize(czm_inverseViewRotation * normalize(reflect(v, n)));
  5767. float vertexRadius = length(positionWC);
  5768. float horizonDotNadir = 1.0 - min(1.0, czm_ellipsoidRadii.x / vertexRadius);
  5769. float reflectionDotNadir = dot(r, normalize(positionWC));
  5770. r.x = -r.x;
  5771. r = -normalize(czm_temeToPseudoFixed * r);
  5772. r.x = -r.x;
  5773. float inverseRoughness = 1.04 - roughness;
  5774. inverseRoughness *= inverseRoughness;
  5775. vec3 sceneSkyBox = textureCube(czm_environmentMap, r).rgb * inverseRoughness;
  5776. float atmosphereHeight = 0.05;
  5777. float blendRegionSize = 0.1 * ((1.0 - inverseRoughness) * 8.0 + 1.1 - horizonDotNadir);
  5778. float blendRegionOffset = roughness * -1.0;
  5779. float farAboveHorizon = clamp(horizonDotNadir - blendRegionSize * 0.5 + blendRegionOffset, 1.0e-10 - blendRegionSize, 0.99999);
  5780. float aroundHorizon = clamp(horizonDotNadir + blendRegionSize * 0.5, 1.0e-10 - blendRegionSize, 0.99999);
  5781. float farBelowHorizon = clamp(horizonDotNadir + blendRegionSize * 1.5, 1.0e-10 - blendRegionSize, 0.99999);
  5782. float smoothstepHeight = smoothstep(0.0, atmosphereHeight, horizonDotNadir);
  5783. vec3 belowHorizonColor = mix(vec3(0.1, 0.15, 0.25), vec3(0.4, 0.7, 0.9), smoothstepHeight);
  5784. vec3 nadirColor = belowHorizonColor * 0.5;
  5785. vec3 aboveHorizonColor = mix(vec3(0.9, 1.0, 1.2), belowHorizonColor, roughness * 0.5);
  5786. vec3 blueSkyColor = mix(vec3(0.18, 0.26, 0.48), aboveHorizonColor, reflectionDotNadir * inverseRoughness * 0.5 + 0.75);
  5787. vec3 zenithColor = mix(blueSkyColor, sceneSkyBox, smoothstepHeight);
  5788. vec3 blueSkyDiffuseColor = vec3(0.7, 0.85, 0.9);
  5789. float diffuseIrradianceFromEarth = (1.0 - horizonDotNadir) * (reflectionDotNadir * 0.25 + 0.75) * smoothstepHeight;
  5790. float diffuseIrradianceFromSky = (1.0 - smoothstepHeight) * (1.0 - (reflectionDotNadir * 0.25 + 0.25));
  5791. vec3 diffuseIrradiance = blueSkyDiffuseColor * clamp(diffuseIrradianceFromEarth + diffuseIrradianceFromSky, 0.0, 1.0);
  5792. float notDistantRough = (1.0 - horizonDotNadir * roughness * 0.8);
  5793. vec3 specularIrradiance = mix(zenithColor, aboveHorizonColor, smoothstep(farAboveHorizon, aroundHorizon, reflectionDotNadir) * notDistantRough);
  5794. specularIrradiance = mix(specularIrradiance, belowHorizonColor, smoothstep(aroundHorizon, farBelowHorizon, reflectionDotNadir) * inverseRoughness);
  5795. specularIrradiance = mix(specularIrradiance, nadirColor, smoothstep(farBelowHorizon, 1.0, reflectionDotNadir) * inverseRoughness);
  5796. float LdotZenith = clamp(dot(normalize(czm_inverseViewRotation * czm_sunDirectionEC), normalize(positionWC * -1.0)), 0.001, 1.0);
  5797. float S = acos(LdotZenith);
  5798. float NdotZenith = clamp(dot(normalize(czm_inverseViewRotation * n), normalize(positionWC * -1.0)), 0.001, 1.0);
  5799. float sunNdotL = clamp(dot(n, czm_sunDirectionEC), 0.001, 1.0);
  5800. float gamma = acos(sunNdotL);
  5801. float numerator = ((0.91 + 10.0 * exp(-3.0 * gamma) + 0.45 * pow(sunNdotL, 2.0)) * (1.0 - exp(-0.32 / NdotZenith)));
  5802. float denominator = (0.91 + 10.0 * exp(-3.0 * S) + 0.45 * pow(LdotZenith,2.0)) * (1.0 - exp(-0.32));
  5803. float luminance = 0.2 * (numerator / denominator);
  5804. irradiance += diffuseIrradiance * luminance;
  5805. radiance += specularIrradiance * luminance;
  5806. #endif
  5807. irradiance *= uEnvMapIntensity;
  5808. radiance *= uEnvMapIntensity;
  5809. indirectSpecular_Physical(radiance, irradiance, geometry, material, reflectedLight);
  5810. #ifdef HAS_OCCLUSION_TEXTURE
  5811. #ifdef USE_BatchPBR
  5812. float ambientOcclusion = texture2DLodEXT(uOcclusionTexture, uv, mipmapLevel).r;
  5813. #else
  5814. float ambientOcclusion = texture2D(uOcclusionTexture, oriTexCoord.xy).r;
  5815. #endif
  5816. reflectedLight.indirectDiffuse *= ambientOcclusion;
  5817. #ifdef IBL
  5818. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  5819. #endif
  5820. #endif
  5821. vec3 color = reflectedLight.directDiffuse + reflectedLight.directSpecular + reflectedLight.indirectDiffuse + reflectedLight.indirectSpecular;
  5822. #ifdef HAS_EMISSIVE_TEXTURE
  5823. emissiveTexCoord = emissiveTexCoord * uEmissiveUVOffsetAndTiling.zw + uEmissiveUVOffsetAndTiling.xy;
  5824. vec3 emissive = texture2D(uEmissionTexture, emissiveTexCoord).rgb;
  5825. emissive *= emissiveFactor.rgb;
  5826. color += emissive;
  5827. #else
  5828. color += emissiveFactor.rgb;
  5829. #endif
  5830. color = applyTonemapping(color);
  5831. color = LinearTosRGB(color);
  5832. #ifdef MASK
  5833. if (baseColorWithAlpha.a < uAlphaCutoff)
  5834. {
  5835. discard;
  5836. }
  5837. return vec4(color.rgb, 1.0);
  5838. #endif
  5839. return vec4(color.rgb, baseColorWithAlpha.a);
  5840. }
  5841. #endif
  5842. `;var gr=`
  5843. #define cubeUV_minMipLevel 4.0
  5844. #define cubeUV_minTileSize 16.0
  5845. #ifdef WEBGL2
  5846. #define texture2DGradEXT textureGrad
  5847. #endif
  5848. // These shader functions convert between the UV coordinates of a single face of
  5849. // a cubemap, the 0-5 integer index of a cube face, and the direction vector for
  5850. // sampling a textureCube (not generally normalized ).
  5851. float getFace( vec3 direction ) {
  5852. vec3 absDirection = abs( direction );
  5853. float face = - 1.0;
  5854. if ( absDirection.x > absDirection.z ) {
  5855. if ( absDirection.x > absDirection.y )
  5856. face = direction.x > 0.0 ? 0.0 : 3.0;
  5857. else
  5858. face = direction.y > 0.0 ? 1.0 : 4.0;
  5859. } else {
  5860. if ( absDirection.z > absDirection.y )
  5861. face = direction.z > 0.0 ? 2.0 : 5.0;
  5862. else
  5863. face = direction.y > 0.0 ? 1.0 : 4.0;
  5864. }
  5865. return face;
  5866. }
  5867. // RH coordinate system; PMREM face-indexing convention
  5868. vec2 getUV( vec3 direction, float face ) {
  5869. vec2 uv;
  5870. if ( face == 0.0 ) {
  5871. uv = vec2( direction.z, direction.y ) / abs( direction.x ); // pos x
  5872. } else if ( face == 1.0 ) {
  5873. uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); // pos y
  5874. } else if ( face == 2.0 ) {
  5875. uv = vec2( - direction.x, direction.y ) / abs( direction.z ); // pos z
  5876. } else if ( face == 3.0 ) {
  5877. uv = vec2( - direction.z, direction.y ) / abs( direction.x ); // neg x
  5878. } else if ( face == 4.0 ) {
  5879. uv = vec2( - direction.x, direction.z ) / abs( direction.y ); // neg y
  5880. } else {
  5881. uv = vec2( direction.x, direction.y ) / abs( direction.z ); // neg z
  5882. }
  5883. return 0.5 * ( uv + 1.0 );
  5884. }
  5885. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  5886. float face = getFace( direction );
  5887. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  5888. mipInt = max( mipInt, cubeUV_minMipLevel );
  5889. float faceSize = exp2( mipInt );
  5890. vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  5891. if ( face > 2.0 ) {
  5892. uv.y += faceSize;
  5893. face -= 3.0;
  5894. }
  5895. uv.x += face * faceSize;
  5896. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  5897. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  5898. uv.x *= CUBEUV_TEXEL_WIDTH;
  5899. uv.y *= CUBEUV_TEXEL_HEIGHT;
  5900. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; // disable anisotropic filtering
  5901. }
  5902. // These defines must match with PMREMGenerator
  5903. #define cubeUV_r0 1.0
  5904. #define cubeUV_v0 0.339
  5905. #define cubeUV_m0 - 2.0
  5906. #define cubeUV_r1 0.8
  5907. #define cubeUV_v1 0.276
  5908. #define cubeUV_m1 - 1.0
  5909. #define cubeUV_r4 0.4
  5910. #define cubeUV_v4 0.046
  5911. #define cubeUV_m4 2.0
  5912. #define cubeUV_r5 0.305
  5913. #define cubeUV_v5 0.016
  5914. #define cubeUV_m5 3.0
  5915. #define cubeUV_r6 0.21
  5916. #define cubeUV_v6 0.0038
  5917. #define cubeUV_m6 4.0
  5918. float roughnessToMip( float roughness ) {
  5919. float mip = 0.0;
  5920. if ( roughness >= cubeUV_r1 ) {
  5921. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  5922. } else if ( roughness >= cubeUV_r4 ) {
  5923. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  5924. } else if ( roughness >= cubeUV_r5 ) {
  5925. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  5926. } else if ( roughness >= cubeUV_r6 ) {
  5927. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  5928. } else {
  5929. mip = - 2.0 * log2( 1.16 * roughness ); // 1.16 = 1.79^0.25
  5930. }
  5931. return mip;
  5932. }
  5933. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  5934. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  5935. float mipF = fract( mip );
  5936. float mipInt = floor( mip );
  5937. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  5938. if ( mipF == 0.0 ) {
  5939. return vec4( color0, 1.0 );
  5940. } else {
  5941. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  5942. return vec4( mix( color0, color1, mipF ), 1.0 );
  5943. }
  5944. }
  5945. `;var _r=`
  5946. #ifdef HAS_MAPBOX_MAP
  5947. precision mediump sampler2DArray;
  5948. uniform sampler2D u_mapboxIndexTexture;
  5949. uniform sampler2D u_innerMapboxIndexTexture;//\u7CBE\u7EC6\u7D22\u5F15\u7EB9\u7406
  5950. uniform sampler2D u_relativeBoundsTexture;
  5951. uniform sampler2DArray u_mapboxTileTextureArray;
  5952. vec2 calUVFromGeoBounds(vec2 geoCoord, vec4 geoBounds) {
  5953. if(geoBounds.z > czm_pi && geoCoord.x < 0.0 ){
  5954. geoCoord.x += czm_twoPi;
  5955. }
  5956. vec2 uv = geoCoord.xy - vec2(geoBounds.x, geoBounds.w);
  5957. uv.x = uv.x / (geoBounds.z - geoBounds.x);
  5958. uv.y = 1.0 - uv.y / (geoBounds.y - geoBounds.w);
  5959. return uv;
  5960. }
  5961. bool isValidTexCoord(vec2 inUV){
  5962. if(inUV.x < 0.0 || inUV.x > 1.0 || inUV.y < 0.0 || inUV.y > 1.0){
  5963. return false;
  5964. }
  5965. return true;
  5966. }
  5967. //geoBounds's lng should be [-PI, 2PI]
  5968. bool isGeoPosInGeoBounds(vec2 geoTexCoord, vec4 mapboxGeoBounds){
  5969. if(mapboxGeoBounds.z > czm_pi && geoTexCoord.x < 0.0){
  5970. geoTexCoord.x += czm_twoPi;
  5971. }
  5972. return geoTexCoord.x > mapboxGeoBounds.x &&
  5973. geoTexCoord.x < mapboxGeoBounds.z &&
  5974. geoTexCoord.y > mapboxGeoBounds.y &&
  5975. geoTexCoord.y < mapboxGeoBounds.w;
  5976. }
  5977. bool isInInnerIndexTextureGeoBounds(vec2 geoTexCoord, vec4 innerIndexTextureGeoBounds){
  5978. if(innerIndexTextureGeoBounds.x > innerIndexTextureGeoBounds.z || innerIndexTextureGeoBounds.y > innerIndexTextureGeoBounds.w){
  5979. return false;
  5980. }
  5981. return isGeoPosInGeoBounds(geoTexCoord, innerIndexTextureGeoBounds);
  5982. }
  5983. vec4 calIndexByPointInsideGeoBounds(vec2 geoTexCoord, vec4 mapboxGeoBounds, vec4 innerIndexTextureGeoBounds){
  5984. vec2 indexTextureCoord;
  5985. vec4 indexTextureColor;
  5986. //\u5224\u65AD\u8BE5\u70B9\u662F\u5426\u5728\u7CBE\u7EC6\u7D22\u5F15\u7EB9\u7406\u7684\u8303\u56F4\u5185
  5987. if(isInInnerIndexTextureGeoBounds(geoTexCoord, innerIndexTextureGeoBounds)){
  5988. //\u8BE5\u70B9\u5728\u7CBE\u7EC6\u7D22\u5F15\u7EB9\u7406\u7684\u8303\u56F4\u5185\uFF0C\u4ECE\u7CBE\u7EC6\u7D22\u5F15\u7EB9\u7406\u53D6\u7D22\u5F15
  5989. indexTextureCoord = calUVFromGeoBounds(geoTexCoord, innerIndexTextureGeoBounds);
  5990. indexTextureColor = textureLod(u_innerMapboxIndexTexture, indexTextureCoord, 0.0);
  5991. if(indexTextureColor.r == 0.0){
  5992. //\u4ECE\u7CBE\u7EC6\u7D22\u5F15\u7EB9\u7406\u91CC\u53D6\u4E0D\u5230\u7D22\u5F15\uFF0C\u5C31\u4ECE\u4E3B\u7EB9\u7406\u53D6
  5993. indexTextureCoord = calUVFromGeoBounds(geoTexCoord, mapboxGeoBounds);
  5994. indexTextureColor = textureLod(u_mapboxIndexTexture, indexTextureCoord, 0.0);
  5995. }
  5996. }else{
  5997. //\u8BE5\u70B9\u4E0D\u5728\u7CBE\u7EC6\u7D22\u5F15\u7EB9\u7406\u7684\u8303\u56F4\u5185\uFF0C\u4ECE\u4E3B\u7D22\u5F15\u7EB9\u7406\u53D6\u7D22\u5F15
  5998. indexTextureCoord = calUVFromGeoBounds(geoTexCoord, mapboxGeoBounds);
  5999. indexTextureColor = textureLod(u_mapboxIndexTexture, indexTextureCoord, 0.0);
  6000. }
  6001. return indexTextureColor;
  6002. }
  6003. struct MapboxMapParam {
  6004. vec2 relativeTileBoundsCoord;
  6005. vec4 tileBounds;
  6006. vec4 mapboxGeoBounds;
  6007. vec4 innerMapboxGeoBounds; //\u7CBE\u7EC6\u7D22\u5F15\u7EB9\u7406\u7684\u5730\u7406\u8303\u56F4
  6008. float mapboxAlpha;
  6009. };
  6010. vec4 getMapboxMapColor(vec4 inColor, MapboxMapParam param){
  6011. // \u8BA1\u7B97\u5F53\u524D\u70B9\u7684\u5730\u7406\u5750\u6807
  6012. vec2 geoTexCoord = param.relativeTileBoundsCoord.xy;
  6013. geoTexCoord.x = geoTexCoord.x * (param.tileBounds.z - param.tileBounds.x) + param.tileBounds.x;
  6014. geoTexCoord.y = geoTexCoord.y * (param.tileBounds.w - param.tileBounds.y) + param.tileBounds.y;
  6015. // \u5224\u65AD\u662F\u5426\u5728mapbox\u5730\u56FE\u8986\u76D6\u7684\u5730\u7406\u8303\u56F4\u5185
  6016. if(isGeoPosInGeoBounds(geoTexCoord, param.mapboxGeoBounds))
  6017. {
  6018. // \u8BA1\u7B97\u5728mapbox\u7D22\u5F15\u7EB9\u7406\u4E0A\u7684\u5750\u6807\u5E76\u83B7\u5F97\u5F53\u524D\u70B9\u5728mapbox\u7684tile\u7684\u7EB9\u7406\u6570\u7EC4\u4E2D\u7684\u7D22\u5F15\u53F7
  6019. vec4 indexTextureColor = calIndexByPointInsideGeoBounds(geoTexCoord, param.mapboxGeoBounds, param.innerMapboxGeoBounds);
  6020. if(indexTextureColor.r > 0.0)
  6021. {
  6022. float textureIndex = floor(indexTextureColor.r);
  6023. // \u8BA1\u7B97\u5F53\u524D\u70B9\u5728mapbox\u7684tile\u7EB9\u7406\u4E2D\u7684\u5750\u6807\u5E76\u83B7\u53D6\u6700\u7EC8\u989C\u8272
  6024. vec4 mapboxTileRelativeBounds = texelFetch(u_relativeBoundsTexture, ivec2(textureIndex , 0), 0);
  6025. vec2 mapboxTileTextureCoord = (param.relativeTileBoundsCoord.xy - mapboxTileRelativeBounds.rg) / mapboxTileRelativeBounds.ba;
  6026. if(!isValidTexCoord(mapboxTileTextureCoord)){
  6027. for(int i = 0; i < MAXBOX_TILE_TEXTURE_SIZE; i++){
  6028. mapboxTileRelativeBounds = texelFetch(u_relativeBoundsTexture, ivec2(i , 0), 0);
  6029. mapboxTileTextureCoord = (param.relativeTileBoundsCoord.xy - mapboxTileRelativeBounds.rg) / mapboxTileRelativeBounds.ba;
  6030. if(isValidTexCoord(mapboxTileTextureCoord)){
  6031. textureIndex = float(i);
  6032. break;
  6033. }
  6034. }
  6035. }
  6036. // return vec4(1.0, .0, 0., 0.5);
  6037. #ifdef WEBGPU
  6038. vec4 mapboxColor = textureLod(u_mapboxTileTextureArray, vec3(mapboxTileTextureCoord, textureIndex), 0.0);
  6039. #else
  6040. vec4 mapboxColor = texture(u_mapboxTileTextureArray, vec3(mapboxTileTextureCoord, textureIndex));
  6041. #endif
  6042. if(mapboxColor.a < 0.001){
  6043. return inColor;
  6044. }
  6045. vec4 blendColor = inColor;
  6046. float finalApha = param.mapboxAlpha * mapboxColor.a;
  6047. blendColor.rgb = mapboxColor.rgb * param.mapboxAlpha + inColor.rgb * (1.0 -finalApha);
  6048. return blendColor;
  6049. }
  6050. }
  6051. return inColor;
  6052. }
  6053. #endif
  6054. `;var xr=`
  6055. varying vec2 v_clippingPosition;
  6056. flat varying int v_regionIndex;
  6057. uniform highp sampler2D u_clippingExtentsTexture;
  6058. uniform highp int uClippingPolygonRegionsLength;
  6059. vec2 getLookupUv(vec2 dimensions, int i) {
  6060. int pixY = i / int(dimensions.x);
  6061. int pixX = i - (pixY * int(dimensions.x));
  6062. float pixelWidth = 1.0 / dimensions.x;
  6063. float pixelHeight = 1.0 / dimensions.y;
  6064. float u = (float(pixX) + 0.5) * pixelWidth; // sample from center of pixel
  6065. float v = (float(pixY) + 0.5) * pixelHeight;
  6066. return vec2(u, v);
  6067. }
  6068. vec4 unpackClippingExtents(highp sampler2D extentsTexture, int index) {
  6069. vec2 textureDimensions = vec2(textureSize(extentsTexture, 0));
  6070. return texture(extentsTexture, getLookupUv(textureDimensions, index));
  6071. }
  6072. void calcClipRegionIndexAndUV(vec3 positionWC) {
  6073. #ifdef SCENE3D
  6074. vec2 sphericalLatLong = czm_approximateSphericalCoordinates(positionWC);
  6075. #else
  6076. vec2 sphericalLatLong = vec2(positionWC.z / 6378137.0, positionWC.y / 6378137.0);
  6077. #endif
  6078. sphericalLatLong.y = czm_branchFreeTernary(sphericalLatLong.y < czm_pi, sphericalLatLong.y, sphericalLatLong.y - czm_twoPi);
  6079. vec2 minDistance = vec2(czm_infinity);
  6080. v_regionIndex = -1;
  6081. v_clippingPosition = vec2(czm_infinity);
  6082. for (int regionIndex = 0; regionIndex < uClippingPolygonRegionsLength; regionIndex++) {
  6083. vec4 extents = unpackClippingExtents(u_clippingExtentsTexture, regionIndex);
  6084. vec2 rectUv = (sphericalLatLong.yx - extents.yx) * extents.wz;
  6085. vec2 clamped = clamp(rectUv, vec2(0.0), vec2(1.0));
  6086. vec2 distance = abs(rectUv - clamped) * extents.wz;
  6087. if (minDistance.x > distance.x || minDistance.y > distance.y) {
  6088. minDistance = distance;
  6089. v_clippingPosition = rectUv;
  6090. }
  6091. float threshold = 0.01;
  6092. if (rectUv.x > threshold && rectUv.y > threshold && rectUv.x < 1.0 - threshold && rectUv.y < 1.0 - threshold) {
  6093. v_regionIndex = regionIndex;
  6094. }
  6095. }
  6096. }
  6097. `;var Cr=`
  6098. uniform highp sampler2D u_SignedDistanceTexture;
  6099. uniform highp sampler2D u_clippingExtentsTexture;
  6100. uniform vec2 u_SignedDistanceTextureSize;
  6101. uniform highp int uClippingPolygonRegionsLength;
  6102. uniform float uExtentsDimension;
  6103. varying vec3 v_positionMC;
  6104. float getSignedDistance(vec2 uv) {
  6105. float signedDistance = czm_unpackDepth(textureLod(u_SignedDistanceTexture, uv, 0.0));
  6106. return (signedDistance - 0.5) * 2.0;
  6107. }
  6108. vec2 getLookupUv(vec2 dimensions, int i) {
  6109. int pixY = i / int(dimensions.x);
  6110. int pixX = i - (pixY * int(dimensions.x));
  6111. float pixelWidth = 1.0 / dimensions.x;
  6112. float pixelHeight = 1.0 / dimensions.y;
  6113. float u = (float(pixX) + 0.5) * pixelWidth; // sample from center of pixel
  6114. float v = (float(pixY) + 0.5) * pixelHeight;
  6115. return vec2(u, v);
  6116. }
  6117. vec4 unpackClippingExtents(int index) {
  6118. vec2 textureDim = vec2(textureSize(u_clippingExtentsTexture, 0));
  6119. return texture(u_clippingExtentsTexture, getLookupUv(textureDim, index));
  6120. }
  6121. void calcClipRegionIndexAndUV(vec3 positionMC, out vec2 clippingPosition, out int outRegionIndex) {
  6122. vec2 minDistance = vec2(czm_infinity);
  6123. outRegionIndex = -1;
  6124. clippingPosition = vec2(czm_infinity);
  6125. for (int regionIndex = 0; regionIndex < uClippingPolygonRegionsLength; regionIndex++) {
  6126. vec4 extents = unpackClippingExtents(regionIndex);
  6127. vec2 rectUv = (positionMC.xy - extents.xy) * extents.zw;
  6128. vec2 clamped = clamp(rectUv, vec2(0.0), vec2(1.0));
  6129. vec2 distance = abs(rectUv - clamped) * extents.zw;
  6130. float threshold = 0.01;
  6131. if (minDistance.x > distance.x || minDistance.y > distance.y) {
  6132. minDistance = distance;
  6133. if (rectUv.x > threshold && rectUv.y > threshold && rectUv.x < 1.0 - threshold && rectUv.y < 1.0 - threshold) {
  6134. outRegionIndex = regionIndex;
  6135. clippingPosition = rectUv;
  6136. }
  6137. }
  6138. }
  6139. }
  6140. void clipPolygons() {
  6141. // Position is completely outside of polygons bounds
  6142. vec2 rectUv;
  6143. int regionIndex;
  6144. calcClipRegionIndexAndUV(v_positionMC, rectUv, regionIndex);
  6145. if (regionIndex < 0 || rectUv.x <= 0.0 || rectUv.y <= 0.0 || rectUv.x >= 1.0 || rectUv.y >= 1.0) {
  6146. #ifdef CLIPPING_INVERSE
  6147. discard;
  6148. #endif
  6149. return;
  6150. }
  6151. vec2 sampleOffset = max(1.0 / u_SignedDistanceTextureSize, vec2(0.005));
  6152. float dimension = uExtentsDimension;
  6153. vec2 textureOffset = vec2(mod(float(regionIndex), dimension), floor(float(regionIndex) / dimension)) / dimension;
  6154. vec2 uv = textureOffset + rectUv / dimension;
  6155. float signedDistance = getSignedDistance(uv);
  6156. #ifdef CLIPPING_INVERSE
  6157. if (signedDistance > 0.0) {
  6158. discard;
  6159. }
  6160. #else
  6161. if (signedDistance < 0.0) {
  6162. discard;
  6163. }
  6164. #endif
  6165. }
  6166. `;var Tr=`
  6167. #ifdef LOG_DEPTH
  6168. varying float v_depthFromNearPlusOne;
  6169. #endif
  6170. #ifdef POLYGON_OFFSET
  6171. uniform vec4 uPolygonOffset;
  6172. #endif
  6173. void writeLogDepth(float depth)
  6174. {
  6175. #ifdef LOG_DEPTH
  6176. #if defined(GL_EXT_frag_depth) || defined(WEBGL2)
  6177. if (depth <= 0.9999999 || depth > czm_farDepthFromNearPlusOne) {
  6178. discard;
  6179. }
  6180. #ifdef POLYGON_OFFSET
  6181. float factor = uPolygonOffset.z;
  6182. float units = uPolygonOffset.w;
  6183. #if defined(GL_OES_standard_derivatives) || defined(WEBGL2)
  6184. float x = dFdx(depth);
  6185. float y = dFdy(depth);
  6186. float m = sqrt(x * x + y * y);
  6187. depth += m * factor;
  6188. #endif
  6189. #endif
  6190. gl_FragDepthEXT = log2(depth) * czm_oneOverLog2FarDepthFromNearPlusOne;
  6191. #ifdef POLYGON_OFFSET
  6192. gl_FragDepthEXT += czm_epsilon7 * units;
  6193. #endif
  6194. #endif
  6195. #endif
  6196. }
  6197. `;var $i={rainDecl:sr,snowDecl:fr,hemisphereLightDecl:ur,pointLightDecl:mr,spotLightDecl:dr,directionLightDecl:pr,lightSourceImpl:vr,brdf:hr,cubeUV_reflection:gr,getMapboxColor:_r,clipPolygonsVS:xr,clipPolygonsFS:Cr,writeLogDepthDecl:Tr},yr=$i;function zr(e){return e=e.replace(/\/\/.*/g,""),e.replace(/\/\*\*[\s\S]*?\*\//gm,function(n){for(var t=n.match(/\n/gm).length,o="",r=0;r<t;++r)o+=`
  6198. `;return o})}function br(e,n,t){for(var o,r=0;r<t.length;++r)t[r].name===e&&(o=t[r]);return u(o)||(n=zr(n),o={name:e,glslSource:n,dependsOn:[],requiredBy:[],evaluated:!1},t.push(o)),o}function wr(e,n){if(!e.evaluated){e.evaluated=!0;var t=e.glslSource.match(/\bczm_[a-zA-Z0-9_]*/g);u(t)&&t!==null&&(t=t.filter(function(o,r){return t.indexOf(o)===r}),t.forEach(function(o){if(o!==e.name&&I._czmBuiltinsAndUniforms.hasOwnProperty(o)){var r=br(o,I._czmBuiltinsAndUniforms[o],n);e.dependsOn.push(r),r.requiredBy.push(e),wr(r,n)}}))}}function ea(e){for(var n=[],t=[];e.length>0;){var o=e.pop();t.push(o),o.requiredBy.length===0&&n.push(o)}for(;n.length>0;){var r=n.shift();e.push(r);for(var i=0;i<r.dependsOn.length;++i){var l=r.dependsOn[i],m=l.requiredBy.indexOf(r);l.requiredBy.splice(m,1),l.requiredBy.length===0&&n.push(l)}}for(var f=[],v=0;v<t.length;++v)t[v].requiredBy.length!==0&&f.push(t[v]);if(f.length!==0){for(var p=`A circular dependency was found in the following built-in functions/structs/constants:
  6199. `,s=0;s<f.length;++s)p=p+f[s].name+`
  6200. `;throw new x(p)}}function na(e,n,t){var o=[],r=br("main",n,o);wr(r,o),ea(o);for(var i="",l=o.length-1;l>=0;--l)Lr(t,e)&&(o[l].glslSource=Xe.removeUnuseMacroCode(t,e,o[l].glslSource)),i=i+o[l].glslSource+`
  6201. `;return i.replace(r.glslSource,"")}function Lr(e,n){return!(!u(e)||!u(n)||!e.shaderPreprocess)}function Sr(e){var n=/^[ \t]*#include +<([\w\d./]+)>/gm;function t(o,r){var i=yr[r];if(i===void 0)throw new Error("Can not resolve #include <"+r+">");return Sr(i)}return e.replace(n,t)}function Er(e,n,t){var o,r,i="",l=e.sources;if(u(l))for(o=0,r=l.length;o<r;++o)i+=`
  6202. #line 0
  6203. `+l[o];i=zr(i);var m;i=i.replace(/#version\s+(.*?)\n/gm,function(y,S){if(u(m)&&m!==S)throw new x("inconsistent versions found: "+m+" and "+S);return m=S,`
  6204. `});var f=[];i=i.replace(/#extension.*\n/gm,function(y){return f.push(y),`
  6205. `}),i=i.replace(/precision\s(lowp|mediump|highp)\s(float|int);/,"");var v=e.pickColorQualifier;u(v)&&(i=I.createPickFragmentShaderSource(i,v));var p="";u(m)&&(p="#version "+m+`
  6206. `);var s=f.length;for(o=0;o<s;o++)p+=f[o];n&&(p+=`#ifdef GL_FRAGMENT_PRECISION_HIGH
  6207. precision highp float;
  6208. #else
  6209. precision mediump float;
  6210. #endif
  6211. `);var d=e.defines;if(u(d))for(o=0,r=d.length;o<r;++o){var g=d[o];g.length!==0&&(p+="#define "+g+`
  6212. `)}if(t.webgl2&&(p+=`#define OUTPUT_DECLARATION
  6213. `,p+=`#define WEBGL2
  6214. `,p+=`#define texture2DLodEXT textureLod
  6215. `,p+=`#define texture2DGradEXT textureGrad
  6216. `),i=Sr(i),t.textureFloatLinear&&(p+=`#define OES_texture_float_linear
  6217. `),Lr(t,e)&&(i=Xe.removeUnuseMacroCode(t,e,i)),e.includeBuiltIns){var C=na(e,i,t);for(f.length=0,C=C.replace(/#extension.*\n/gm,function(y){return f.push(y),`
  6218. `}),s=f.length,o=0;o<s;o++)p=f[o]+p;p+=C}return p+=`
  6219. #line 0
  6220. `,p+=i,t.webgl2&&(p=gn(p,n,!0)),p}function I(e){e=h(e,h.EMPTY_OBJECT);var n=e.pickColorQualifier;if(u(n)&&n!=="uniform"&&n!=="varying")throw new x("options.pickColorQualifier must be 'uniform' or 'varying'.");this.defines=u(e.defines)?e.defines.slice(0):[],this.sources=u(e.sources)?e.sources.slice(0):[],this.pickColorQualifier=n,this.includeBuiltIns=h(e.includeBuiltIns,!0),this.name=u(e.name)?e.name:void 0}I.prototype.clone=function(){return new I({sources:this.sources,defines:this.defines,name:this.name,pickColorQualifier:this.pickColorQualifier,includeBuiltIns:this.includeBuiltIns})};I.replaceMain=function(e,n){return n="void "+n+"()",e.replace(/void\s+main\s*\(\s*(?:void)?\s*\)/g,n)};I.prototype.getCacheKey=function(e){let t=this.defines.slice().sort().join(","),o=this.pickColorQualifier||"",r=this.includeBuiltIns,i=this.sources.join(`
  6221. `);return`${t}:${o}:${i}`};I.prototype.createCombinedVertexShader=function(e){return Er(this,!1,e)};I.prototype.createCombinedFragmentShader=function(e){return Er(this,!0,e)};I._czmBuiltinsAndUniforms={};for(Me in Re)Re.hasOwnProperty(Me)&&(I._czmBuiltinsAndUniforms[Me]=Re[Me]);var Me;for(Ee in Ce)Ce.hasOwnProperty(Ee)&&(Ye=Ce[Ee],typeof Ye.getDeclaration=="function"&&(I._czmBuiltinsAndUniforms[Ee]=Ye.getDeclaration(Ee)));var Ye,Ee;I.createPickVertexShaderSource=function(e){var n=I.replaceMain(e,"czm_old_main"),t=`attribute vec4 pickColor;
  6222. varying vec4 czm_pickColor;
  6223. void main()
  6224. {
  6225. czm_old_main();
  6226. czm_pickColor = pickColor;
  6227. }`;return n+`
  6228. `+t};I.createPickFragmentShaderSource=function(e,n){var t=I.replaceMain(e,"czm_old_main"),o=n+` vec4 czm_pickColor;
  6229. void main()
  6230. {
  6231. czm_old_main();
  6232. if (gl_FragColor.a == 0.0) {
  6233. discard;
  6234. }
  6235. gl_FragColor = czm_pickColor;
  6236. }`;return t+`
  6237. `+o};I.findVarying=function(e,n){for(var t=e.sources,o=n.length,r=0;r<o;++r)for(var i=n[r],l=t.length,m=0;m<l;++m)if(t[m].indexOf(i)!==-1)return i};var ta=["v_normalEC","v_normal","aNormal"];I.findNormalVarying=function(e){return I.findVarying(e,ta)};var oa=["v_positionEC"];I.findPositionVarying=function(e){return I.findVarying(e,oa)};var je=I;function ra(e,n,t,o){switch(n.type){case e.FLOAT:return new Ar(e,n,t,o);case e.FLOAT_VEC2:return new Dr(e,n,t,o);case e.FLOAT_VEC3:return new Or(e,n,t,o);case e.FLOAT_VEC4:return new Ir(e,n,t,o);case e.SAMPLER_2D:case e.SAMPLER_CUBE:return new Ze(e,n,t,o);case e.SAMPLER_2D_ARRAY:case e.SAMPLER_3D:return new Ke(e,n,t,o);case e.INT:case e.BOOL:return new Rr(e,n,t,o);case e.INT_VEC2:case e.BOOL_VEC2:return new Mr(e,n,t,o);case e.INT_VEC3:case e.BOOL_VEC3:return new Pr(e,n,t,o);case e.INT_VEC4:case e.BOOL_VEC4:return new Vr(e,n,t,o);case e.FLOAT_MAT2:return new Fr(e,n,t,o);case e.FLOAT_MAT3:return new Br(e,n,t,o);case e.FLOAT_MAT4:return new Nr(e,n,t,o);default:throw new ne("Unrecognized uniform type: "+n.type+' for uniform "'+t+'".')}}function Ar(e,n,t,o){this.name=t,this.value=void 0,this._value=0,this._gl=e,this._location=o}Ar.prototype.set=function(){this.value!==this._value&&(this._value=this.value,this._gl.uniform1f(this._location,this.value))};function Dr(e,n,t,o){this.name=t,this.value=void 0,this._value=new A,this._gl=e,this._location=o}Dr.prototype.set=function(){var e=this.value;A.equals(e,this._value)||(A.clone(e,this._value),this._gl.uniform2f(this._location,e.x,e.y))};function Or(e,n,t,o){this.name=t,this.value=void 0,this._value=void 0,this._gl=e,this._location=o}Or.prototype.set=function(){var e=this.value;if(u(e.red))J.equals(e,this._value)||(this._value=J.clone(e,this._value),this._gl.uniform3f(this._location,e.red,e.green,e.blue));else if(u(e.x))a.equals(e,this._value)||(this._value=a.clone(e,this._value),this._gl.uniform3f(this._location,e.x,e.y,e.z));else throw new x('Invalid vec3 value for uniform "'+this.name+'".')};function Ir(e,n,t,o){this.name=t,this.value=void 0,this._value=void 0,this._gl=e,this._location=o}Ir.prototype.set=function(){var e=this.value;if(u(e.red))J.equals(e,this._value)||(this._value=J.clone(e,this._value),this._gl.uniform4f(this._location,e.red,e.green,e.blue,e.alpha));else if(u(e.x))H.equals(e,this._value)||(this._value=H.clone(e,this._value),this._gl.uniform4f(this._location,e.x,e.y,e.z,e.w));else throw new x('Invalid vec4 value for uniform "'+this.name+'".')};function Ze(e,n,t,o){this.name=t,this.value=void 0,this._gl=e,this._location=o,this.textureUnitIndex=void 0}Ze.prototype.set=function(){var e=this._gl;e.activeTexture(e.TEXTURE0+this.textureUnitIndex);var n=this.value;e.bindTexture(n._target,n._texture)};Ze.prototype._setSampler=function(e){return this.textureUnitIndex=e,this._gl.uniform1i(this._location,e),e+1};function Ke(e,n,t,o){this.name=t,this.value=void 0,this._gl=e,this._location=o,this.textureUnitIndex=void 0}Ke.prototype.set=function(){var e=this.value,n=this._gl;n.activeTexture(n.TEXTURE0+this.textureUnitIndex),n.bindTexture(e._target,e._texture)};Ke.prototype._setSampler=function(e){return this.textureUnitIndex=e,this._gl.uniform1i(this._location,e),e+1};function Rr(e,n,t,o){this.name=t,this.value=void 0,this._value=0,this._gl=e,this._location=o}Rr.prototype.set=function(){this.value!==this._value&&(this._value=this.value,this._gl.uniform1i(this._location,this.value))};function Mr(e,n,t,o){this.name=t,this.value=void 0,this._value=new A,this._gl=e,this._location=o}Mr.prototype.set=function(){var e=this.value;A.equals(e,this._value)||(A.clone(e,this._value),this._gl.uniform2i(this._location,e.x,e.y))};function Pr(e,n,t,o){this.name=t,this.value=void 0,this._value=new a,this._gl=e,this._location=o}Pr.prototype.set=function(){var e=this.value;a.equals(e,this._value)||(a.clone(e,this._value),this._gl.uniform3i(this._location,e.x,e.y,e.z))};function Vr(e,n,t,o){this.name=t,this.value=void 0,this._value=new H,this._gl=e,this._location=o}Vr.prototype.set=function(){var e=this.value;H.equals(e,this._value)||(H.clone(e,this._value),this._gl.uniform4i(this._location,e.x,e.y,e.z,e.w))};var ia=new Float32Array(4);function Fr(e,n,t,o){this.name=t,this.value=void 0,this._value=new se,this._gl=e,this._location=o}Fr.prototype.set=function(){if(!se.equalsArray(this.value,this._value,0)){se.clone(this.value,this._value);var e=se.toArray(this.value,ia);this._gl.uniformMatrix2fv(this._location,!1,e)}};var aa=new Float32Array(9);function Br(e,n,t,o){this.name=t,this.value=void 0,this._value=new T,this._gl=e,this._location=o}Br.prototype.set=function(){if(!T.equalsArray(this.value,this._value,0)){T.clone(this.value,this._value);var e=T.toArray(this.value,aa);this._gl.uniformMatrix3fv(this._location,!1,e)}};var la=new Float32Array(16);function Nr(e,n,t,o){this.name=t,this.value=void 0,this._value=new G,this._gl=e,this._location=o}Nr.prototype.set=function(){if(!G.equalsArray(this.value,this._value,0)){G.clone(this.value,this._value);var e=G.toArray(this.value,la);this._gl.uniformMatrix4fv(this._location,!1,e)}};var Hr=ra;function ca(e,n,t,o){switch(n.type){case e.FLOAT:return new Ur(e,n,t,o);case e.FLOAT_VEC2:return new Gr(e,n,t,o);case e.FLOAT_VEC3:return new kr(e,n,t,o);case e.FLOAT_VEC4:return new Wr(e,n,t,o);case e.SAMPLER_2D:case e.SAMPLER_CUBE:return new Qe(e,n,t,o);case e.INT:case e.BOOL:return new qr(e,n,t,o);case e.INT_VEC2:case e.BOOL_VEC2:return new Xr(e,n,t,o);case e.INT_VEC3:case e.BOOL_VEC3:return new Yr(e,n,t,o);case e.INT_VEC4:case e.BOOL_VEC4:return new jr(e,n,t,o);case e.FLOAT_MAT2:return new Zr(e,n,t,o);case e.FLOAT_MAT3:return new Kr(e,n,t,o);case e.FLOAT_MAT4:return new Qr(e,n,t,o);default:throw new ne("Unrecognized uniform type: "+n.type+' for uniform "'+t+'".')}}function Ur(e,n,t,o){var r=o.length;this.name=t,this.value=new Array(r),this._value=new Float32Array(r),this._gl=e,this._location=o[0]}Ur.prototype.set=function(){for(var e=this.value,n=e.length,t=this._value,o=!1,r=0;r<n;++r){var i=e[r];i!==t[r]&&(t[r]=i,o=!0)}o&&this._gl.uniform1fv(this._location,t)};function Gr(e,n,t,o){var r=o.length;this.name=t,this.value=new Array(r),this._value=new Float32Array(r*2),this._gl=e,this._location=o[0]}Gr.prototype.set=function(){for(var e=this.value,n=e.length,t=this._value,o=!1,r=0,i=0;i<n;++i){var l=e[i];A.equalsArray(l,t,r)||(A.pack(l,t,r),o=!0),r+=2}o&&this._gl.uniform2fv(this._location,t)};function kr(e,n,t,o){var r=o.length;this.name=t,this.value=new Array(r),this._value=new Float32Array(r*3),this._gl=e,this._location=o[0]}kr.prototype.set=function(){for(var e=this.value,n=e.length,t=this._value,o=!1,r=0,i=0;i<n;++i){var l=e[i];if(u(l.red))(l.red!==t[r]||l.green!==t[r+1]||l.blue!==t[r+2])&&(t[r]=l.red,t[r+1]=l.green,t[r+2]=l.blue,o=!0);else if(u(l.x))a.equalsArray(l,t,r)||(a.pack(l,t,r),o=!0);else throw new x("Invalid vec3 value.");r+=3}o&&this._gl.uniform3fv(this._location,t)};function Wr(e,n,t,o){var r=o.length;this.name=t,this.value=new Array(r),this._value=new Float32Array(r*4),this._gl=e,this._location=o[0]}Wr.prototype.set=function(){for(var e=this.value,n=e.length,t=this._value,o=!1,r=0,i=0;i<n;++i){var l=e[i];if(u(l.red))J.equalsArray(l,t,r)||(J.pack(l,t,r),o=!0);else if(u(l.x))H.equalsArray(l,t,r)||(H.pack(l,t,r),o=!0);else throw new x("Invalid vec4 value.");r+=4}o&&this._gl.uniform4fv(this._location,t)};function Qe(e,n,t,o){var r=o.length;this.name=t,this.value=new Array(r),this._value=new Float32Array(r),this._gl=e,this._locations=o,this.textureUnitIndex=void 0}Qe.prototype.set=function(){for(var e=this._gl,n=e.TEXTURE0+this.textureUnitIndex,t=this.value,o=t.length,r=0;r<o;++r){var i=t[r];e.activeTexture(n+r),e.bindTexture(i._target,i._texture)}};Qe.prototype._setSampler=function(e){this.textureUnitIndex=e;for(var n=this._locations,t=n.length,o=0;o<t;++o){var r=e+o;this._gl.uniform1i(n[o],r)}return e+t};function qr(e,n,t,o){var r=o.length;this.name=t,this.value=new Array(r),this._value=new Int32Array(r),this._gl=e,this._location=o[0]}qr.prototype.set=function(){for(var e=this.value,n=e.length,t=this._value,o=!1,r=0;r<n;++r){var i=e[r];i!==t[r]&&(t[r]=i,o=!0)}o&&this._gl.uniform1iv(this._location,t)};function Xr(e,n,t,o){var r=o.length;this.name=t,this.value=new Array(r),this._value=new Int32Array(r*2),this._gl=e,this._location=o[0]}Xr.prototype.set=function(){for(var e=this.value,n=e.length,t=this._value,o=!1,r=0,i=0;i<n;++i){var l=e[i];A.equalsArray(l,t,r)||(A.pack(l,t,r),o=!0),r+=2}o&&this._gl.uniform2iv(this._location,t)};function Yr(e,n,t,o){var r=o.length;this.name=t,this.value=new Array(r),this._value=new Int32Array(r*3),this._gl=e,this._location=o[0]}Yr.prototype.set=function(){for(var e=this.value,n=e.length,t=this._value,o=!1,r=0,i=0;i<n;++i){var l=e[i];a.equalsArray(l,t,r)||(a.pack(l,t,r),o=!0),r+=3}o&&this._gl.uniform3iv(this._location,t)};function jr(e,n,t,o){var r=o.length;this.name=t,this.value=new Array(r),this._value=new Int32Array(r*4),this._gl=e,this._location=o[0]}jr.prototype.set=function(){for(var e=this.value,n=e.length,t=this._value,o=!1,r=0,i=0;i<n;++i){var l=e[i];H.equalsArray(l,t,r)||(H.pack(l,t,r),o=!0),r+=4}o&&this._gl.uniform4iv(this._location,t)};function Zr(e,n,t,o){var r=o.length;this.name=t,this.value=new Array(r),this._value=new Float32Array(r*4),this._gl=e,this._location=o[0]}Zr.prototype.set=function(){for(var e=this.value,n=e.length,t=this._value,o=!1,r=0,i=0;i<n;++i){var l=e[i];se.equalsArray(l,t,r)||(se.pack(l,t,r),o=!0),r+=4}o&&this._gl.uniformMatrix2fv(this._location,!1,t)};function Kr(e,n,t,o){var r=o.length;this.name=t,this.value=new Array(r),this._value=new Float32Array(r*9),this._gl=e,this._location=o[0]}Kr.prototype.set=function(){for(var e=this.value,n=e.length,t=this._value,o=!1,r=0,i=0;i<n;++i){var l=e[i];T.equalsArray(l,t,r)||(T.pack(l,t,r),o=!0),r+=9}o&&this._gl.uniformMatrix3fv(this._location,!1,t)};function Qr(e,n,t,o){var r=o.length;this.name=t,this.value=new Array(r),this._value=new Float32Array(r*16),this._gl=e,this._location=o[0]}Qr.prototype.set=function(){for(var e=this.value,n=e.length,t=this._value,o=!1,r=0,i=0;i<n;++i){var l=e[i];G.equalsArray(l,t,r)||(G.pack(l,t,r),o=!0),r+=16}o&&this._gl.uniformMatrix4fv(this._location,!1,t)};var Jr=ca;var sa=0;function le(e){var n=fa(e.vertexShaderText,e.fragmentShaderText);this._gl=e.gl,this._logShaderCompilation=e.logShaderCompilation,this._debugShaders=e.debugShaders,this._attributeLocations=e.attributeLocations,this._varyings=e.varyings,this._bufferMode=e.bufferMode,this._program=void 0,this._numberOfVertexAttributes=void 0,this._vertexAttributes=void 0,this._uniformsByName=void 0,this._uniforms=void 0,this._automaticUniforms=void 0,this._manualUniforms=void 0,this._duplicateUniformNames=n.duplicateUniformNames,this._cachedShader=void 0,this._uniformBlockLocation={},this.maximumTextureUnitIndex=void 0,this._vertexShaderSource=e.vertexShaderSource,this._vertexShaderText=e.vertexShaderText,this._fragmentShaderSource=e.fragmentShaderSource,this._fragmentShaderText=n.fragmentShaderText,this.id=sa++}le.fromCache=function(e){return e=h(e,h.EMPTY_OBJECT),q.defined("options.context",e.context),e.context.shaderCache.getShaderProgram(e)};le.replaceCache=function(e){return e=h(e,h.EMPTY_OBJECT),q.defined("options.context",e.context),e.context.shaderCache.replaceShaderProgram(e)};Object.defineProperties(le.prototype,{vertexShaderSource:{get:function(){return this._vertexShaderSource}},fragmentShaderSource:{get:function(){return this._fragmentShaderSource}},vertexAttributes:{get:function(){return Pe(this),this._vertexAttributes}},numberOfVertexAttributes:{get:function(){return Pe(this),this._numberOfVertexAttributes}},allUniforms:{get:function(){return Pe(this),this._uniformsByName}}});function $r(e){var n=[],t=e.match(/uniform.*?(?![^{]*})(?=[=\[;])/g);if(u(t))for(var o=t.length,r=0;r<o;r++){var i=t[r].trim(),l=i.slice(i.lastIndexOf(" ")+1);n.push(l)}return n}function fa(e,n){var t={};if(!Z.highpFloatSupported||!Z.highpIntSupported){var o,r,i,l,m=$r(e),f=$r(n),v=m.length,p=f.length;for(o=0;o<v;o++)for(r=0;r<p;r++)if(m[o]===f[r]){i=m[o],l="czm_mediump_"+i;var s=new RegExp(i+"\\b","g");n=n.replace(s,l),t[l]=i}}return{fragmentShaderText:n,duplicateUniformNames:t}}var K="[Cesium WebGL] ";function ua(e,n){var t=n._vertexShaderText,o=n._fragmentShaderText,r=e.createShader(e.VERTEX_SHADER);e.shaderSource(r,t),e.compileShader(r);var i=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(i,o),e.compileShader(i);var l=e.createProgram();e.attachShader(l,r),e.attachShader(l,i),e.deleteShader(r),e.deleteShader(i);var m=n._attributeLocations;if(u(m))for(var f in m)m.hasOwnProperty(f)&&e.bindAttribLocation(l,m[f],f);var v=n._varyings,p=n._bufferMode;u(v)&&u(p)&&e.transformFeedbackVaryings(l,v,p),e.linkProgram(l);var s;if(!e.getProgramParameter(l,e.LINK_STATUS)){var d=n._debugShaders;if(!e.getShaderParameter(i,e.COMPILE_STATUS)){if(s=e.getShaderInfoLog(i),console.error(K+"Fragment shader compile log: "+s),u(d)){var g=d.getTranslatedShaderSource(i);console.error(g!==""?K+`Translated fragment shader source:
  6238. `+g:K+"Fragment shader translation failed.")}throw e.deleteProgram(l),new ne("Fragment shader failed to compile. Compile log: "+s)}if(!e.getShaderParameter(r,e.COMPILE_STATUS)){if(s=e.getShaderInfoLog(r),console.error(K+"Vertex shader compile log: "+s),u(d)){var C=d.getTranslatedShaderSource(r);console.error(C!==""?K+`Translated vertex shader source:
  6239. `+C:K+"Vertex shader translation failed.")}throw e.deleteProgram(l),new ne("Vertex shader failed to compile. Compile log: "+s)}throw s=e.getProgramInfoLog(l),console.error(K+"Shader program link log: "+s),u(d)&&(console.error(K+`Translated vertex shader source:
  6240. `+d.getTranslatedShaderSource(r)),console.error(K+`Translated fragment shader source:
  6241. `+d.getTranslatedShaderSource(i))),e.deleteProgram(l),new ne("Program failed to link. Link log: "+s)}var y=n._logShaderCompilation;return y&&(s=e.getShaderInfoLog(r),u(s)&&s.length>0&&console.log(K+"Vertex shader compile log: "+s)),y&&(s=e.getShaderInfoLog(i),u(s)&&s.length>0&&console.log(K+"Fragment shader compile log: "+s)),y&&(s=e.getProgramInfoLog(l),u(s)&&s.length>0&&console.log(K+"Shader program link log: "+s)),l}function ma(e,n,t){for(var o={},r=0;r<t;++r){var i=e.getActiveAttrib(n,r),l=e.getAttribLocation(n,i.name);o[i.name]={name:i.name,type:i.type,index:l}}return o}function da(e,n){for(var t={},o=[],r=[],i=e.getProgramParameter(n,e.ACTIVE_UNIFORMS),l=0;l<i;++l){var m=e.getActiveUniform(n,l),f="[0]",v=m.name.indexOf(f,m.name.length-f.length)!==-1?m.name.slice(0,m.name.length-3):m.name;if(v.indexOf("gl_")!==0)if(m.name.indexOf("[")<0){var p=e.getUniformLocation(n,v);if(p!==null){var s=Hr(e,m,v,p);t[v]=s,o.push(s),s._setSampler&&r.push(s)}}else{var d,g,C,y,S=v.indexOf("[");if(S>=0){if(d=t[v.slice(0,S)],!u(d))continue;g=d._locations,g.length<=1&&(C=d.value,y=e.getUniformLocation(n,v),y!==null&&(g.push(y),C.push(e.getUniform(n,y))))}else{g=[];for(var O=0;O<m.size;++O)y=e.getUniformLocation(n,v+"["+O+"]"),y!==null&&g.push(y);d=Jr(e,m,v,g),t[v]=d,o.push(d),d._setSampler&&r.push(d)}}}return{uniformsByName:t,uniforms:o,samplerUniforms:r}}function pa(e,n){var t=[],o=[];for(var r in n)if(n.hasOwnProperty(r)){var i=n[r],l=r,m=e._duplicateUniformNames[l];u(m)&&(i.name=m,l=m);var f=Ce[l];u(f)?t.push({uniform:i,automaticUniform:f}):o.push(i)}return{automaticUniforms:t,manualUniforms:o}}function va(e,n,t){e.useProgram(n);for(var o=0,r=t.length,i=0;i<r;++i)o=t[i]._setSampler(o);return e.useProgram(null),o}function Pe(e){if(!u(e._program)){var n=e._gl,t=ua(n,e,e._debugShaders),o=n.getProgramParameter(t,n.ACTIVE_ATTRIBUTES),r=da(n,t),i=pa(e,r.uniformsByName);e._program=t,e._numberOfVertexAttributes=o,e._vertexAttributes=ma(n,t,o),e._uniformsByName=r.uniformsByName,e._uniforms=r.uniforms,e._automaticUniforms=i.automaticUniforms,e._manualUniforms=i.manualUniforms,e.maximumTextureUnitIndex=va(n,t,r.samplerUniforms)}}le.prototype._bind=function(){Pe(this),this._gl.useProgram(this._program)};le.prototype._setUniforms=function(e,n,t){var o,r;if(u(e)){var i=this._manualUniforms;for(o=i.length,r=0;r<o;++r){var l=i[r];l.value=e[l.name]()}}var m=this._automaticUniforms;for(o=m.length,r=0;r<o;++r){var f=m[r];f.uniform.value=f.automaticUniform.getValue(n)}var v=this._uniforms;for(o=v.length,r=0;r<o;++r)v[r].set();if(t){var p=this._gl,s=this._program;if(p.validateProgram(s),!p.getProgramParameter(s,p.VALIDATE_STATUS))throw new x("Program validation failed. Program info log: "+p.getProgramInfoLog(s))}};le.prototype.isDestroyed=function(){return!1};le.prototype.destroy=function(){this._cachedShader.cache.releaseShaderProgram(this)};le.prototype.finalDestroy=function(){return this._gl.deleteProgram(this._program),Ie(this)};var ei=le;var ha={ADD:c.FUNC_ADD,SUBTRACT:c.FUNC_SUBTRACT,REVERSE_SUBTRACT:c.FUNC_REVERSE_SUBTRACT,MIN:c.MIN,MAX:c.MAX},ve=Object.freeze(ha);var ga={ZERO:c.ZERO,ONE:c.ONE,SOURCE_COLOR:c.SRC_COLOR,ONE_MINUS_SOURCE_COLOR:c.ONE_MINUS_SRC_COLOR,DESTINATION_COLOR:c.DST_COLOR,ONE_MINUS_DESTINATION_COLOR:c.ONE_MINUS_DST_COLOR,SOURCE_ALPHA:c.SRC_ALPHA,ONE_MINUS_SOURCE_ALPHA:c.ONE_MINUS_SRC_ALPHA,DESTINATION_ALPHA:c.DST_ALPHA,ONE_MINUS_DESTINATION_ALPHA:c.ONE_MINUS_DST_ALPHA,CONSTANT_COLOR:c.CONSTANT_COLOR,ONE_MINUS_CONSTANT_COLOR:c.ONE_MINUS_CONSTANT_COLOR,CONSTANT_ALPHA:c.CONSTANT_ALPHA,ONE_MINUS_CONSTANT_ALPHA:c.ONE_MINUS_CONSTANT_ALPHA,SOURCE_ALPHA_SATURATE:c.SRC_ALPHA_SATURATE},Y=Object.freeze(ga);var _a={DISABLED:Object.freeze({enabled:!1}),ALPHA_BLEND:Object.freeze({enabled:!0,equationRgb:ve.ADD,equationAlpha:ve.ADD,functionSourceRgb:Y.SOURCE_ALPHA,functionSourceAlpha:Y.ONE,functionDestinationRgb:Y.ONE_MINUS_SOURCE_ALPHA,functionDestinationAlpha:Y.ONE_MINUS_SOURCE_ALPHA}),PRE_MULTIPLIED_ALPHA_BLEND:Object.freeze({enabled:!0,equationRgb:ve.ADD,equationAlpha:ve.ADD,functionSourceRgb:Y.ONE,functionSourceAlpha:Y.ONE,functionDestinationRgb:Y.ONE_MINUS_SOURCE_ALPHA,functionDestinationAlpha:Y.ONE_MINUS_SOURCE_ALPHA}),ADDITIVE_BLEND:Object.freeze({enabled:!0,equationRgb:ve.ADD,equationAlpha:ve.ADD,functionSourceRgb:Y.SOURCE_ALPHA,functionSourceAlpha:Y.ONE,functionDestinationRgb:Y.ONE,functionDestinationAlpha:Y.ONE})},Wp=Object.freeze(_a);function ni(e){if(typeof e!="object"||e===null)return e;for(var n,t=Object.keys(e),o=0;o<t.length;o++)n=t[o],e.hasOwnProperty(n)&&n!=="_applyFunctions"&&(e[n]=ni(e[n]));return Object.freeze(e)}var ti=ni;function oi(e){return e===c.FUNC_ADD||e===c.FUNC_SUBTRACT||e===c.FUNC_REVERSE_SUBTRACT||e===c.MIN||e===c.MAX}function Ve(e){return e===c.ZERO||e===c.ONE||e===c.SRC_COLOR||e===c.ONE_MINUS_SRC_COLOR||e===c.DST_COLOR||e===c.ONE_MINUS_DST_COLOR||e===c.SRC_ALPHA||e===c.ONE_MINUS_SRC_ALPHA||e===c.DST_ALPHA||e===c.ONE_MINUS_DST_ALPHA||e===c.CONSTANT_COLOR||e===c.ONE_MINUS_CONSTANT_COLOR||e===c.CONSTANT_ALPHA||e===c.ONE_MINUS_CONSTANT_ALPHA||e===c.SRC_ALPHA_SATURATE}function xa(e){return e===c.FRONT||e===c.BACK||e===c.FRONT_AND_BACK}function Ca(e){return e===c.NEVER||e===c.LESS||e===c.EQUAL||e===c.LEQUAL||e===c.GREATER||e===c.NOTEQUAL||e===c.GEQUAL||e===c.ALWAYS}function ri(e){return e===c.NEVER||e===c.LESS||e===c.EQUAL||e===c.LEQUAL||e===c.GREATER||e===c.NOTEQUAL||e===c.GEQUAL||e===c.ALWAYS}function Te(e){return e===c.ZERO||e===c.KEEP||e===c.REPLACE||e===c.INCR||e===c.DECR||e===c.INVERT||e===c.INCR_WRAP||e===c.DECR_WRAP}function oe(e){var n=h(e,{}),t=h(n.cull,{}),o=h(n.polygonOffset,{}),r=h(n.scissorTest,{}),i=h(r.rectangle,{}),l=h(n.depthRange,{}),m=h(n.depthTest,{}),f=h(n.colorMask,{}),v=h(n.blending,{}),p=h(v.color,{}),s=h(n.stencilTest,{}),d=h(s.frontOperation,{}),g=h(s.backOperation,{}),C=h(n.sampleCoverage,{}),y=n.viewport;if(this.frontFace=h(n.frontFace,We.COUNTER_CLOCKWISE),this.cull={enabled:h(t.enabled,!1),face:h(t.face,c.BACK)},this.lineWidth=h(n.lineWidth,1),this.polygonOffset={enabled:h(o.enabled,!1),factor:h(o.factor,0),units:h(o.units,0)},this.scissorTest={enabled:h(r.enabled,!1),rectangle:xe.clone(i)},this.depthRange={near:h(l.near,0),far:h(l.far,1)},this.depthTest={enabled:h(m.enabled,!1),func:h(m.func,c.LESS)},this.colorMask={red:h(f.red,!0),green:h(f.green,!0),blue:h(f.blue,!0),alpha:h(f.alpha,!0)},this.depthMask=h(n.depthMask,!0),this.stencilMask=h(n.stencilMask,-1),this.blending={enabled:h(v.enabled,!1),color:new J(h(p.red,0),h(p.green,0),h(p.blue,0),h(p.alpha,0)),equationRgb:h(v.equationRgb,c.FUNC_ADD),equationAlpha:h(v.equationAlpha,c.FUNC_ADD),functionSourceRgb:h(v.functionSourceRgb,c.ONE),functionSourceAlpha:h(v.functionSourceAlpha,c.ONE),functionDestinationRgb:h(v.functionDestinationRgb,c.ZERO),functionDestinationAlpha:h(v.functionDestinationAlpha,c.ZERO)},this.stencilTest={enabled:h(s.enabled,!1),frontFunction:h(s.frontFunction,c.ALWAYS),backFunction:h(s.backFunction,c.ALWAYS),reference:h(s.reference,0),mask:h(s.mask,-1),frontOperation:{fail:h(d.fail,c.KEEP),zFail:h(d.zFail,c.KEEP),zPass:h(d.zPass,c.KEEP)},backOperation:{fail:h(g.fail,c.KEEP),zFail:h(g.zFail,c.KEEP),zPass:h(g.zPass,c.KEEP)}},this.sampleCoverage={enabled:h(C.enabled,!1),value:h(C.value,1),invert:h(C.invert,!1)},this.viewport=u(y)?new xe(y.x,y.y,y.width,y.height):void 0,this.lineWidth<Z.minimumAliasedLineWidth||this.lineWidth>Z.maximumAliasedLineWidth)throw new x("renderState.lineWidth is out of range. Check minimumAliasedLineWidth and maximumAliasedLineWidth.");if(!We.validate(this.frontFace))throw new x("Invalid renderState.frontFace.");if(!xa(this.cull.face))throw new x("Invalid renderState.cull.face.");if(this.scissorTest.rectangle.width<0||this.scissorTest.rectangle.height<0)throw new x("renderState.scissorTest.rectangle.width and renderState.scissorTest.rectangle.height must be greater than or equal to zero.");if(this.depthRange.near>this.depthRange.far)throw new x("renderState.depthRange.near can not be greater than renderState.depthRange.far.");if(this.depthRange.near<0)throw new x("renderState.depthRange.near must be greater than or equal to zero.");if(this.depthRange.far>1)throw new x("renderState.depthRange.far must be less than or equal to one.");if(!Ca(this.depthTest.func))throw new x("Invalid renderState.depthTest.func.");if(this.blending.color.red<0||this.blending.color.red>1||this.blending.color.green<0||this.blending.color.green>1||this.blending.color.blue<0||this.blending.color.blue>1||this.blending.color.alpha<0||this.blending.color.alpha>1)throw new x("renderState.blending.color components must be greater than or equal to zero and less than or equal to one.");if(!oi(this.blending.equationRgb))throw new x("Invalid renderState.blending.equationRgb.");if(!oi(this.blending.equationAlpha))throw new x("Invalid renderState.blending.equationAlpha.");if(!Ve(this.blending.functionSourceRgb))throw new x("Invalid renderState.blending.functionSourceRgb.");if(!Ve(this.blending.functionSourceAlpha))throw new x("Invalid renderState.blending.functionSourceAlpha.");if(!Ve(this.blending.functionDestinationRgb))throw new x("Invalid renderState.blending.functionDestinationRgb.");if(!Ve(this.blending.functionDestinationAlpha))throw new x("Invalid renderState.blending.functionDestinationAlpha.");if(!ri(this.stencilTest.frontFunction))throw new x("Invalid renderState.stencilTest.frontFunction.");if(!ri(this.stencilTest.backFunction))throw new x("Invalid renderState.stencilTest.backFunction.");if(!Te(this.stencilTest.frontOperation.fail))throw new x("Invalid renderState.stencilTest.frontOperation.fail.");if(!Te(this.stencilTest.frontOperation.zFail))throw new x("Invalid renderState.stencilTest.frontOperation.zFail.");if(!Te(this.stencilTest.frontOperation.zPass))throw new x("Invalid renderState.stencilTest.frontOperation.zPass.");if(!Te(this.stencilTest.backOperation.fail))throw new x("Invalid renderState.stencilTest.backOperation.fail.");if(!Te(this.stencilTest.backOperation.zFail))throw new x("Invalid renderState.stencilTest.backOperation.zFail.");if(!Te(this.stencilTest.backOperation.zPass))throw new x("Invalid renderState.stencilTest.backOperation.zPass.");if(u(this.viewport)){if(this.viewport.width<0)throw new x("renderState.viewport.width must be greater than or equal to zero.");if(this.viewport.height<0)throw new x("renderState.viewport.height must be greater than or equal to zero.");if(this.viewport.width>Z.maximumViewportWidth)throw new x("renderState.viewport.width must be less than or equal to the maximum viewport width ("+Z.maximumViewportWidth.toString()+"). Check maximumViewportWidth.");if(this.viewport.height>Z.maximumViewportHeight)throw new x("renderState.viewport.height must be less than or equal to the maximum viewport height ("+Z.maximumViewportHeight.toString()+"). Check maximumViewportHeight.")}this.id=0,this._applyFunctions=[]}var Ta=0,te={};oe.fromCache=function(e){var n=JSON.stringify(e),t=te[n];if(u(t))return++t.referenceCount,t.state;var o=new oe(e),r=JSON.stringify(o);return t=te[r],u(t)||(o.id=Ta++,o=ti(o),t={referenceCount:0,state:o},te[r]=t),++t.referenceCount,te[n]={referenceCount:1,state:t.state},t.state};oe.removeFromCache=function(e){var n=new oe(e),t=JSON.stringify(n),o=te[t],r=JSON.stringify(e),i=te[r];u(i)&&(--i.referenceCount,i.referenceCount===0&&(delete te[r],u(o)&&--o.referenceCount)),u(o)&&o.referenceCount===0&&delete te[t]};oe.getCache=function(){return te};oe.clearCache=function(){te={}};function he(e,n,t){t?e.enable(n):e.disable(n)}function ii(e,n){e.frontFace(n.frontFace)}function ai(e,n){var t=n.cull,o=t.enabled;he(e,e.CULL_FACE,o),o&&e.cullFace(t.face)}function li(e,n){e.lineWidth(n.lineWidth)}function ci(e,n){var t=n.polygonOffset,o=t.enabled;he(e,e.POLYGON_OFFSET_FILL,o),o&&e.polygonOffset(t.factor,t.units)}function si(e,n,t){var o=n.scissorTest,r=u(t.scissorTest)?t.scissorTest.enabled:o.enabled;if(he(e,e.SCISSOR_TEST,r),r){var i=u(t.scissorTest)?t.scissorTest.rectangle:o.rectangle;e.scissor(i.x,i.y,i.width,i.height)}}function fi(e,n){var t=n.depthRange;e.depthRange(t.near,t.far)}function ui(e,n){var t=n.depthTest,o=t.enabled;he(e,e.DEPTH_TEST,o),o&&e.depthFunc(t.func)}function mi(e,n){var t=n.colorMask;e.colorMask(t.red,t.green,t.blue,t.alpha)}function di(e,n){e.depthMask(n.depthMask)}function pi(e,n){e.stencilMask(n.stencilMask)}function ya(e,n){e.blendColor(n.red,n.green,n.blue,n.alpha)}function vi(e,n,t){var o=n.blending,r=u(t.blendingEnabled)?t.blendingEnabled:o.enabled;he(e,e.BLEND,r),r&&(ya(e,o.color),e.blendEquationSeparate(o.equationRgb,o.equationAlpha),e.blendFuncSeparate(o.functionSourceRgb,o.functionDestinationRgb,o.functionSourceAlpha,o.functionDestinationAlpha))}function hi(e,n){var t=n.stencilTest,o=t.enabled;if(he(e,e.STENCIL_TEST,o),o){var r=t.frontFunction,i=t.backFunction,l=t.reference,m=t.mask;e.stencilFunc(r,l,m),e.stencilFuncSeparate(e.BACK,i,l,m),e.stencilFuncSeparate(e.FRONT,r,l,m);var f=t.frontOperation,v=f.fail,p=f.zFail,s=f.zPass;e.stencilOpSeparate(e.FRONT,v,p,s);var d=t.backOperation,g=d.fail,C=d.zFail,y=d.zPass;e.stencilOpSeparate(e.BACK,g,C,y)}}function gi(e,n){var t=n.sampleCoverage,o=t.enabled;he(e,e.SAMPLE_COVERAGE,o),o&&e.sampleCoverage(t.value,t.invert)}var za=new xe;function _i(e,n,t){var o=h(n.viewport,t.viewport);u(o)||(o=za,o.width=t.context.drawingBufferWidth,o.height=t.context.drawingBufferHeight),t.context.uniformState.viewport=o,e.viewport(o.x,o.y,o.width,o.height)}oe.apply=function(e,n,t){ii(e,n),ai(e,n),li(e,n),ci(e,n),fi(e,n),ui(e,n),mi(e,n),di(e,n),pi(e,n),hi(e,n),gi(e,n),si(e,n,t),vi(e,n,t),_i(e,n,t)};function ba(e,n){var t=[];return e.frontFace!==n.frontFace&&t.push(ii),(e.cull.enabled!==n.cull.enabled||e.cull.face!==n.cull.face)&&t.push(ai),e.lineWidth!==n.lineWidth&&t.push(li),(e.polygonOffset.enabled!==n.polygonOffset.enabled||e.polygonOffset.factor!==n.polygonOffset.factor||e.polygonOffset.units!==n.polygonOffset.units)&&t.push(ci),(e.depthRange.near!==n.depthRange.near||e.depthRange.far!==n.depthRange.far)&&t.push(fi),(e.depthTest.enabled!==n.depthTest.enabled||e.depthTest.func!==n.depthTest.func)&&t.push(ui),(e.colorMask.red!==n.colorMask.red||e.colorMask.green!==n.colorMask.green||e.colorMask.blue!==n.colorMask.blue||e.colorMask.alpha!==n.colorMask.alpha)&&t.push(mi),e.depthMask!==n.depthMask&&t.push(di),e.stencilMask!==n.stencilMask&&t.push(pi),(e.stencilTest.enabled!==n.stencilTest.enabled||e.stencilTest.frontFunction!==n.stencilTest.frontFunction||e.stencilTest.backFunction!==n.stencilTest.backFunction||e.stencilTest.reference!==n.stencilTest.reference||e.stencilTest.mask!==n.stencilTest.mask||e.stencilTest.frontOperation.fail!==n.stencilTest.frontOperation.fail||e.stencilTest.frontOperation.zFail!==n.stencilTest.frontOperation.zFail||e.stencilTest.backOperation.fail!==n.stencilTest.backOperation.fail||e.stencilTest.backOperation.zFail!==n.stencilTest.backOperation.zFail||e.stencilTest.backOperation.zPass!==n.stencilTest.backOperation.zPass)&&t.push(hi),(e.sampleCoverage.enabled!==n.sampleCoverage.enabled||e.sampleCoverage.value!==n.sampleCoverage.value||e.sampleCoverage.invert!==n.sampleCoverage.invert)&&t.push(gi),t}oe.partialApply=function(e,n,t,o,r,i,l,m){if(n!==t){var f=t._applyFunctions[n.id];u(f)||(f=ba(n,t),t._applyFunctions[n.id]=f);for(var v=f.length,p=0;p<v;++p)f[p](e,t)}var s=u(o.scissorTest)?o.scissorTest:n.scissorTest,d=u(r.scissorTest)?r.scissorTest:t.scissorTest;(s!==d||m)&&si(e,t,r);var g=u(o.blendingEnabled)?o.blendingEnabled:n.blending.enabled,C=u(r.blendingEnabled)?r.blendingEnabled:t.blending.enabled;(g!==C||C&&n.blending!==t.blending)&&vi(e,t,r),(n!==t||o!==r||o.context!==r.context||i!==l)&&_i(e,t,r)};oe.getState=function(e){if(!u(e))throw new x("renderState is required.");return{frontFace:e.frontFace,cull:{enabled:e.cull.enabled,face:e.cull.face},lineWidth:e.lineWidth,polygonOffset:{enabled:e.polygonOffset.enabled,factor:e.polygonOffset.factor,units:e.polygonOffset.units},scissorTest:{enabled:e.scissorTest.enabled,rectangle:xe.clone(e.scissorTest.rectangle)},depthRange:{near:e.depthRange.near,far:e.depthRange.far},depthTest:{enabled:e.depthTest.enabled,func:e.depthTest.func},colorMask:{red:e.colorMask.red,green:e.colorMask.green,blue:e.colorMask.blue,alpha:e.colorMask.alpha},depthMask:e.depthMask,stencilMask:e.stencilMask,blending:{enabled:e.blending.enabled,color:J.clone(e.blending.color),equationRgb:e.blending.equationRgb,equationAlpha:e.blending.equationAlpha,functionSourceRgb:e.blending.functionSourceRgb,functionSourceAlpha:e.blending.functionSourceAlpha,functionDestinationRgb:e.blending.functionDestinationRgb,functionDestinationAlpha:e.blending.functionDestinationAlpha},stencilTest:{enabled:e.stencilTest.enabled,frontFunction:e.stencilTest.frontFunction,backFunction:e.stencilTest.backFunction,reference:e.stencilTest.reference,mask:e.stencilTest.mask,frontOperation:{fail:e.stencilTest.frontOperation.fail,zFail:e.stencilTest.frontOperation.zFail,zPass:e.stencilTest.frontOperation.zPass},backOperation:{fail:e.stencilTest.backOperation.fail,zFail:e.stencilTest.backOperation.zFail,zPass:e.stencilTest.backOperation.zPass}},sampleCoverage:{enabled:e.sampleCoverage.enabled,value:e.sampleCoverage.value,invert:e.sampleCoverage.invert},viewport:u(e.viewport)?xe.clone(e.viewport):void 0}};var xi=oe;var wa={ENVIRONMENT:0,COMPUTE:1,GLOBE:2,TERRAIN_CLASSIFICATION:3,CESIUM_3D_TILE:4,CESIUM_3D_TILE_CLASSIFICATION:5,CESIUM_3D_TILE_CLASSIFICATION_IGNORE_SHOW:6,S3MTiles:8,S3MTilesClampObjectStencil:9,S3MTilesClampObjectColor:10,ProjectionImage:11,OPAQUE:12,ClampObject:13,NonClampObject:14,Label_Billboard:15,Voxel_Billboard:16,Particle:17,TRANSLUCENT:18,ANALYSIS:19,LOG_DEPTH_OVERLAY:20,OVERLAY:21,OVERLAY_AGAINST_DEPTH:22,NUMBER_OF_PASSES:23},Ci=Object.freeze(wa);var La={FRONT:c.FRONT,BACK:c.BACK,FRONT_AND_BACK:c.FRONT_AND_BACK},Ti=Object.freeze(La);var Sa={NEVER:c.NEVER,LESS:c.LESS,EQUAL:c.EQUAL,LESS_OR_EQUAL:c.LEQUAL,GREATER:c.GREATER,NOT_EQUAL:c.NOTEQUAL,GREATER_OR_EQUAL:c.GEQUAL,ALWAYS:c.ALWAYS},ye=Object.freeze(Sa);var Ea={ZERO:c.ZERO,KEEP:c.KEEP,REPLACE:c.REPLACE,INCREMENT:c.INCR,DECREMENT:c.DECR,INVERT:c.INVERT,INCREMENT_WRAP:c.INCR_WRAP,DECREMENT_WRAP:c.DECR_WRAP},k=Object.freeze(Ea);var Fe={CESIUM_3D_TILE_MASK:128,S3M_TILE:2,MODEL:6,SKIP_LOD_MASK:112,SKIP_LOD_BIT_SHIFT:4,CLASSIFICATION_MASK:15};Fe.setCesium3DTileBit=function(){return{enabled:!0,frontFunction:ye.ALWAYS,frontOperation:{fail:k.KEEP,zFail:k.KEEP,zPass:k.REPLACE},backFunction:ye.ALWAYS,backOperation:{fail:k.KEEP,zFail:k.KEEP,zPass:k.REPLACE},reference:Fe.CESIUM_3D_TILE_MASK,mask:Fe.CESIUM_3D_TILE_MASK}};var Be=Object.freeze(Fe);var z=[];z[0]={num:0,des:"inside"};z[1]={num:4,data:[0,4,7,3],des:"left"};z[2]={num:4,data:[1,2,6,5],des:"right"};z[3]={num:0};z[4]={num:4,data:[0,1,5,4],des:"bottom"};z[5]={num:6,data:[0,1,5,4,7,3],des:"bottom, left"};z[6]={num:6,data:[0,1,2,6,5,4],des:"bottom, right"};z[7]={num:0};z[8]={num:4,data:[2,3,7,6],des:"top"};z[9]={num:6,data:[4,7,6,2,3,0],des:"top, left"};z[10]={num:6,data:[2,3,7,6,5,1],des:"top, right"};z[11]={num:0};z[12]={num:0};z[13]={num:0};z[14]={num:0};z[15]={num:0};z[16]={num:4,data:[0,3,2,1],des:"front"};z[17]={num:6,data:[0,4,7,3,2,1],des:"front, left"};z[18]={num:6,data:[0,3,2,6,5,1],des:"front, right"};z[19]={num:0};z[20]={num:6,data:[0,3,2,1,5,4],des:"front, bottom"};z[21]={num:6,data:[2,1,5,4,7,3],des:"front, bottom, left"};z[22]={num:6,data:[0,3,2,6,5,4],des:"front, bottom, right"};z[23]={num:0};z[24]={num:6,data:[0,3,7,6,2,1],des:"front, top"};z[25]={num:6,data:[0,4,7,6,2,1],des:"front, top, left"};z[26]={num:6,data:[0,3,7,6,5,1],des:"front, top, right"};z[27]={num:0};z[28]={num:0};z[29]={num:0};z[30]={num:0};z[31]={num:0};z[32]={num:4,data:[4,5,6,7],des:"back"};z[33]={num:6,data:[4,5,6,7,3,0],des:"back, left"};z[34]={num:6,data:[1,2,6,7,4,5],des:"back, right"};z[35]={num:0};z[36]={num:6,data:[0,1,5,6,7,4],des:"back, bottom"};z[37]={num:6,data:[0,1,5,6,7,3],des:"back, bottom, left"};z[38]={num:6,data:[0,1,2,6,7,4],des:"back, bottom, right"};z[39]={num:0};z[40]={num:6,data:[2,3,7,4,5,6],des:"back, top"};z[41]={num:6,data:[0,4,5,6,2,3],des:"back, top, left"};z[42]={num:6,data:[1,2,3,7,4,5],des:"back, top, right"};function w(e,n){this.center=a.clone(h(e,a.ZERO)),this.halfAxes=T.clone(h(n,T.ZERO)),this.areaDirty=1}w.packedLength=a.packedLength+T.packedLength;w.pack=function(e,n,t){return q.typeOf.object("value",e),q.defined("array",n),t=h(t,0),a.pack(e.center,n,t),T.pack(e.halfAxes,n,t+a.packedLength),n};w.unpack=function(e,n,t){return q.defined("array",e),n=h(n,0),u(t)||(t=new w),a.unpack(e,n,t.center),T.unpack(e,n+a.packedLength,t.halfAxes),t};var Aa=new a,Da=new a,Oa=new a,Ia=new a,Ra=new a,Ma=new a,Pa=new T,Va={unitary:new T,diagonal:new T},ce=new a,Q=new a,L=new a;w.fromPoints=function(e,n){if(u(n)||(n=new w),!u(e)||e.length===0)return n.halfAxes=T.ZERO,n.center=a.ZERO,n;var t,o=e.length,r=a.clone(e[0],Aa);for(t=1;t<o;t++)a.add(r,e[t],r);var i=1/o;a.multiplyByScalar(r,i,r);var l=0,m=0,f=0,v=0,p=0,s=0,d;for(t=0;t<o;t++)d=a.subtract(e[t],r,Da),l+=d.x*d.x,m+=d.x*d.y,f+=d.x*d.z,v+=d.y*d.y,p+=d.y*d.z,s+=d.z*d.z;l*=i,m*=i,f*=i,v*=i,p*=i,s*=i;var g=Pa;g[0]=l,g[1]=m,g[2]=f,g[3]=m,g[4]=v,g[5]=p,g[6]=f,g[7]=p,g[8]=s;var C=T.computeEigenDecomposition(g,Va),y=T.clone(C.unitary,n.halfAxes),S=T.getColumn(y,0,Ia),O=T.getColumn(y,1,Ra),R=T.getColumn(y,2,Ma),U=-Number.MAX_VALUE,V=-Number.MAX_VALUE,D=-Number.MAX_VALUE,F=Number.MAX_VALUE,B=Number.MAX_VALUE,j=Number.MAX_VALUE;for(t=0;t<o;t++)d=e[t],U=Math.max(a.dot(S,d),U),V=Math.max(a.dot(O,d),V),D=Math.max(a.dot(R,d),D),F=Math.min(a.dot(S,d),F),B=Math.min(a.dot(O,d),B),j=Math.min(a.dot(R,d),j);S=a.multiplyByScalar(S,.5*(F+U),S),O=a.multiplyByScalar(O,.5*(B+V),O),R=a.multiplyByScalar(R,.5*(j+D),R);var re=a.add(S,O,n.center);a.add(re,R,re);var W=Oa;return W.x=U-F,W.y=V-B,W.z=D-j,a.multiplyByScalar(W,.5,W),T.multiplyByScale(n.halfAxes,W,n.halfAxes),n};var Si=new a,Fa=new a;function yi(e,n,t,o,r,i,l,m,f,v,p){if(!u(r)||!u(i)||!u(l)||!u(m)||!u(f)||!u(v))throw new x("all extents (minimum/maximum X/Y/Z) are required.");u(p)||(p=new w);var s=p.halfAxes;T.setColumn(s,0,n,s),T.setColumn(s,1,t,s),T.setColumn(s,2,o,s);var d=Si;d.x=(r+i)/2,d.y=(l+m)/2,d.z=(f+v)/2;var g=Fa;g.x=(i-r)/2,g.y=(m-l)/2,g.z=(v-f)/2;var C=p.center;return d=T.multiplyByVector(s,d,d),a.add(e,d,C),T.multiplyByScale(s,g,s),p}var zi=new X,Ba=new a,Na=new X,Ha=new X,Ua=new X,Ga=new X,ka=new X,Wa=new a,bi=new a,qa=new a,wi=new a,Xa=new a,Ya=new A,ja=new A,Za=new A,Ka=new A,Qa=new A,Ja=new a,$a=new a,el=new a,nl=new a,tl=new A,ol=new a,rl=new a,il=new a,al=new de(a.UNIT_X,0);w.fromRectangle=function(e,n,t,o,r){if(!u(e))throw new x("rectangle is required");if(e.width<0||e.width>N.TWO_PI)throw new x("Rectangle width must be between 0 and 2*pi");if(e.height<0||e.height>N.PI)throw new x("Rectangle height must be between 0 and pi");if(u(o)&&!N.equalsEpsilon(o.radii.x,o.radii.y,N.EPSILON15))throw new x("Ellipsoid must be an ellipsoid of revolution (radii.x == radii.y)");n=h(n,0),t=h(t,0),o=h(o,an.WGS84);var i,l,m,f,v,p,s;if(e.width<=N.PI){var d=Ge.center(e,zi),g=o.cartographicToCartesian(d,Ba),C=new sn(g,o);s=C.plane;var y=d.longitude,S=e.south<0&&e.north>0?0:d.latitude,O=X.fromRadians(y,e.north,t,Na),R=X.fromRadians(e.west,e.north,t,Ha),U=X.fromRadians(e.west,S,t,Ua),V=X.fromRadians(e.west,e.south,t,Ga),D=X.fromRadians(y,e.south,t,ka),F=o.cartographicToCartesian(O,Wa),B=o.cartographicToCartesian(R,bi),j=o.cartographicToCartesian(U,qa),re=o.cartographicToCartesian(V,wi),W=o.cartographicToCartesian(D,Xa),ze=C.projectPointToNearestOnPlane(F,Ya),me=C.projectPointToNearestOnPlane(B,ja),ee=C.projectPointToNearestOnPlane(j,Za),be=C.projectPointToNearestOnPlane(re,Ka),Ae=C.projectPointToNearestOnPlane(W,Qa);return i=Math.min(me.x,ee.x,be.x),l=-i,f=Math.max(me.y,ze.y),m=Math.min(be.y,Ae.y),R.height=V.height=n,B=o.cartographicToCartesian(R,bi),re=o.cartographicToCartesian(V,wi),v=Math.min(de.getPointDistance(s,B),de.getPointDistance(s,re)),p=t,yi(C.origin,C.xAxis,C.yAxis,C.zAxis,i,l,m,f,v,p,r)}var we=e.south>0,nn=e.north<0,He=we?e.south:nn?e.north:0,tn=Ge.center(e,zi).longitude,_e=a.fromRadians(tn,He,t,o,Ja);_e.z=0;var Ai=Math.abs(_e.x)<N.EPSILON10&&Math.abs(_e.y)<N.EPSILON10,Ue=Ai?a.UNIT_X:a.normalize(_e,$a),on=a.UNIT_Z,rn=a.cross(Ue,on,el);s=de.fromPointNormal(_e,Ue,al);var Di=a.fromRadians(tn+N.PI_OVER_TWO,He,t,o,nl);l=a.dot(de.projectPointOntoPlane(s,Di,tl),rn),i=-l,f=a.fromRadians(0,e.north,nn?n:t,o,ol).z,m=a.fromRadians(0,e.south,we?n:t,o,rl).z;var Oi=a.fromRadians(e.east,He,t,o,il);return v=de.getPointDistance(s,Oi),p=0,yi(_e,rn,on,Ue,i,l,m,f,v,p,r)};w.clone=function(e,n){if(!!u(e))return u(n)?(a.clone(e.center,n.center),T.clone(e.halfAxes,n.halfAxes),n.areaDirty=1,n):new w(e.center,e.halfAxes)};w.intersectPlane=function(e,n){if(!u(e))throw new x("box is required.");if(!u(n))throw new x("plane is required.");var t=e.center,o=n.normal,r=e.halfAxes,i=o.x,l=o.y,m=o.z,f=Math.abs(i*r[T.COLUMN0ROW0]+l*r[T.COLUMN0ROW1]+m*r[T.COLUMN0ROW2])+Math.abs(i*r[T.COLUMN1ROW0]+l*r[T.COLUMN1ROW1]+m*r[T.COLUMN1ROW2])+Math.abs(i*r[T.COLUMN2ROW0]+l*r[T.COLUMN2ROW1]+m*r[T.COLUMN2ROW2]),v=a.dot(o,t)+n.distance;return v<=-f?De.OUTSIDE:v>=f?De.INSIDE:De.INTERSECTING};var Je=new a,$e=new a,en=new a,ll=new a,cl=new a;w.distanceSquaredTo=function(e,n){if(!u(e))throw new x("box is required.");if(!u(n))throw new x("cartesian is required.");var t=a.subtract(n,e.center,Si),o=e.halfAxes,r=T.getColumn(o,0,Je),i=T.getColumn(o,1,$e),l=T.getColumn(o,2,en),m=a.magnitude(r),f=a.magnitude(i),v=a.magnitude(l);a.normalize(r,r),a.normalize(i,i),a.normalize(l,l);var p=ll;p.x=a.dot(t,r),p.y=a.dot(t,i),p.z=a.dot(t,l);var s=0,d;return p.x<-m?(d=p.x+m,s+=d*d):p.x>m&&(d=p.x-m,s+=d*d),p.y<-f?(d=p.y+f,s+=d*d):p.y>f&&(d=p.y-f,s+=d*d),p.z<-v?(d=p.z+v,s+=d*d):p.z>v&&(d=p.z-v,s+=d*d),s};var Ei=new a,sl=new a;w.computePlaneDistances=function(e,n,t,o){if(!u(e))throw new x("box is required.");if(!u(n))throw new x("position is required.");if(!u(t))throw new x("direction is required.");u(o)||(o=new ln);var r=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,l=e.center,m=e.halfAxes,f=T.getColumn(m,0,Je),v=T.getColumn(m,1,$e),p=T.getColumn(m,2,en),s=a.add(f,v,Ei);a.add(s,p,s),a.add(s,l,s);var d=a.subtract(s,n,sl),g=a.dot(t,d);return r=Math.min(g,r),i=Math.max(g,i),a.add(l,f,s),a.add(s,v,s),a.subtract(s,p,s),a.subtract(s,n,d),g=a.dot(t,d),r=Math.min(g,r),i=Math.max(g,i),a.add(l,f,s),a.subtract(s,v,s),a.add(s,p,s),a.subtract(s,n,d),g=a.dot(t,d),r=Math.min(g,r),i=Math.max(g,i),a.add(l,f,s),a.subtract(s,v,s),a.subtract(s,p,s),a.subtract(s,n,d),g=a.dot(t,d),r=Math.min(g,r),i=Math.max(g,i),a.subtract(l,f,s),a.add(s,v,s),a.add(s,p,s),a.subtract(s,n,d),g=a.dot(t,d),r=Math.min(g,r),i=Math.max(g,i),a.subtract(l,f,s),a.add(s,v,s),a.subtract(s,p,s),a.subtract(s,n,d),g=a.dot(t,d),r=Math.min(g,r),i=Math.max(g,i),a.subtract(l,f,s),a.subtract(s,v,s),a.add(s,p,s),a.subtract(s,n,d),g=a.dot(t,d),r=Math.min(g,r),i=Math.max(g,i),a.subtract(l,f,s),a.subtract(s,v,s),a.subtract(s,p,s),a.subtract(s,n,d),g=a.dot(t,d),r=Math.min(g,r),i=Math.max(g,i),o.start=r,o.stop=i,o};var fl=new ke;w.isOccluded=function(e,n){if(!u(e))throw new x("box is required.");if(!u(n))throw new x("occluder is required.");var t=ke.fromOrientedBoundingBox(e,fl);return!n.isBoundingSphereVisible(t)};w.prototype.intersectPlane=function(e){return w.intersectPlane(this,e)};w.prototype.distanceSquaredTo=function(e){return w.distanceSquaredTo(this,e)};w.prototype.computePlaneDistances=function(e,n,t){return w.computePlaneDistances(this,e,n,t)};w.prototype.isOccluded=function(e){return w.isOccluded(this,e)};w.equals=function(e,n){return e===n||u(e)&&u(n)&&a.equals(e.center,n.center)&&T.equals(e.halfAxes,n.halfAxes)};w.prototype.clone=function(e){return w.clone(this,e)};w.prototype.equals=function(e){return w.equals(this,e)};var Li=new H;w.prototype._updateBBox=function(){if(this.areaDirty==1){var e=T.getColumn(this.halfAxes,0,Je),n=a.clone(a.negate(e,ce)),t=T.getColumn(this.halfAxes,1,$e),o=a.clone(a.negate(t,ce)),r=T.getColumn(this.halfAxes,2,en),i=a.clone(a.negate(r,ce));this.bbox=[],a.add(this.center,t,ce),a.add(ce,i,Q),a.add(Q,n,L),this.bbox[0]=new a(L.x,L.y,L.z),a.add(Q,e,L),this.bbox[1]=new a(L.x,L.y,L.z),a.add(ce,r,Q),a.add(Q,e,L),this.bbox[2]=new a(L.x,L.y,L.z),a.add(Q,n,L),this.bbox[3]=new a(L.x,L.y,L.z),a.add(this.center,o,ce),a.add(ce,i,Q),a.add(Q,n,L),this.bbox[4]=new a(L.x,L.y,L.z),a.add(Q,e,L),this.bbox[5]=new a(L.x,L.y,L.z),a.add(ce,r,Q),a.add(Q,e,L),this.bbox[6]=new a(L.x,L.y,L.z),a.add(Q,n,L),this.bbox[7]=new a(L.x,L.y,L.z);var l=a.magnitude(e),m=a.magnitude(t),f=a.magnitude(r),v=new a(-l,-m,-f),p=new a(l,m,f);if(l*m*f==0){this.areaDirty=-1;return}a.normalize(e,e),a.normalize(t,t),a.normalize(r,r),this.u=a.clone(e),this.v=a.clone(t),this.w=a.clone(r),this.posMin=v,this.posMaX=p,this.areaDirty=0}};var b=void 0;w.prototype._createDeriveZBackfaceCommand=function(e){if(u(this.command))return this.command;this._updateBBox();for(var n=new Float32Array(3*8),t=0;t<8;t++)n[t*3]=this.bbox[t].x-this.center.x,n[t*3+1]=this.bbox[t].y-this.center.y,n[t*3+2]=this.bbox[t].z-this.center.z;u(b)||(b=new Uint8Array(36),b[0]=3,b[1]=2,b[2]=6,b[3]=3,b[4]=6,b[5]=7,b[6]=0,b[7]=4,b[8]=1,b[9]=1,b[10]=4,b[11]=5,b[12]=4,b[13]=6,b[14]=5,b[15]=4,b[16]=7,b[17]=6,b[18]=0,b[19]=3,b[20]=4,b[21]=3,b[22]=7,b[23]=4,b[24]=0,b[25]=1,b[26]=2,b[27]=0,b[28]=2,b[29]=3,b[30]=1,b[31]=5,b[32]=6,b[33]=1,b[34]=6,b[35]=2);var o=fe.createIndexBuffer({context:e,typedArray:b,usage:Se.STATIC_DRAW,indexDatatype:Le.UNSIGNED_BYTE});o.vertexArrayDestroyable=!1,o.referenceCount=1;var r=new dn({context:e,attributes:[{index:0,vertexBuffer:fe.createVertexBuffer({context:e,typedArray:n,usage:Se.STATIC_DRAW}),componentDatatype:M.FLOAT,componentsPerAttribute:3,offsetInBytes:0,strideInBytes:3*M.getSizeInBytes(M.FLOAT)}],indexBuffer:o}),i=["attribute vec4 position;","void main()","{"," gl_Position = czm_modelViewProjection * vec4(position.xyz, 1.0);","}"].join(`
  6242. `),l=["void main()","{"," gl_FragColor = vec4(1.0,0.0,0.0,0.3);","}"].join(`
  6243. `),m=new je({sources:[i]}),f=new je({sources:[l]});this.command=new pn,this.command.cull=!1,this.command.boundingVolume=this,this.command.orientedBoundingBox=this,this.command.shaderProgram=ei.fromCache({context:e,vertexShaderSource:m,fragmentShaderSource:f,attributeLocations:{position:0}});var v=G.fromTranslation(this.center);return this.command.uniformMap={},this.command.modelMatrix=v,this.command.primitiveType=Oe.TRIANGLES,this.command.vertexArray=r,this.command.count=b.length,this.command.pass=Ci.S3MTilesClampObjectStencil,this.command.renderState=xi.fromCache({cull:{enabled:!0,face:Ti.BACK},colorMask:{red:!1,green:!1,blue:!1,alpha:!1},stencilMask:Be.SKIP_LOD_MASK,stencilTest:{enabled:!0,backFunction:ye.NOT_EQUAL,backOperation:{fail:k.KEEP,zFail:k.REPLACE,zPass:k.REPLACE},frontFunction:ye.NOT_EQUAL,frontOperation:{fail:k.KEEP,zFail:k.REPLACE,zPass:k.REPLACE},reference:Be.SKIP_LOD_MASK,mask:Be.SKIP_LOD_MASK}}),this.command};var ge=[];ge.push(new A);ge.push(new A);ge.push(new A);ge.push(new A);ge.push(new A);ge.push(new A);var ul=new X,Ne=new a;w.prototype.calculateBoxArea=function(e,n,t,o,r,i,l,m){this._updateBBox();var f=e,v=a.subtract(f,this.center,cl);if(this.areaDirty==-1){var p=i!=-1?i:a.distance(this.posMaX,this.posMin)*.5,s=r,d=s/o,g=d*p/t;return N.PI*g*g}var C=a.fromElements(a.dot(v,this.u),a.dot(v,this.v),a.dot(v,this.w),Ei),y=C.x<this.posMin.x?1:0,S=C.x>this.posMaX.x?1:0,O=C.z<this.posMin.z?1:0,R=C.z>this.posMaX.z?1:0,U=C.y>this.posMaX.y?1:0,V=C.y<this.posMin.y?1:0,D=y+(S<<1)+(O<<2)+(R<<3)+(U<<4)+(V<<5);if(D>42)return console.log("area calculation is wrong"),-100;var F=z[D];if(F.num==0){var p=i!=-1?i:a.distance(this.posMaX,this.posMin)*.5,s=r,d=s/o,g=d*p/t;return N.PI*g*g}if(F.num==0)return console.log("area calculation is wrong"),-100;for(var B=[],j,re=l,W=0;W<F.num;W++){var ze=ge[W],me=this.bbox[F.data[W]];j=!1;var ee,be=N.PI;if(n===3)ee=G.multiplyByVector(re,H.fromElements(me.x,me.y,me.z,1),Li),ee.z<0&&(j=!0,p==-1&&(be=N.PI_OVER_FOUR,t=a.magnitude(v)));else{var Ae=m,we=Ae.ellipsoid.cartesianToCartographic(me,ul);u(we)?(Ae.project(we,Ne),ee=G.multiplyByVector(re,H.fromElements(Ne.z,Ne.x,Ne.y,1),Li),ee.z<0&&(j=!0)):j=!0}if(j==!0){var p=i!=-1?i:a.distance(this.posMaX,this.posMin)*.5,s=r,d=s/o,g=d*p/t;return be*g*g}else ze.x=ee.x/ee.w,ze.y=r-ee.y/ee.w,B.push(ze)}return Math.abs(fn.computeArea2D(B))};w.prototype.computeCorners=function(e){return w.computeCorners(this,e)};var ml=new a,dl=new a,pl=new a;w.computeCorners=function(e,n){q.typeOf.object("box",e),u(n)||(n=[new a,new a,new a,new a,new a,new a,new a,new a]);let t=e.center,o=e.halfAxes,r=T.getColumn(o,0,ml),i=T.getColumn(o,1,dl),l=T.getColumn(o,2,pl);return a.clone(t,n[0]),a.subtract(n[0],r,n[0]),a.subtract(n[0],i,n[0]),a.subtract(n[0],l,n[0]),a.clone(t,n[1]),a.subtract(n[1],r,n[1]),a.subtract(n[1],i,n[1]),a.add(n[1],l,n[1]),a.clone(t,n[2]),a.subtract(n[2],r,n[2]),a.add(n[2],i,n[2]),a.subtract(n[2],l,n[2]),a.clone(t,n[3]),a.subtract(n[3],r,n[3]),a.add(n[3],i,n[3]),a.add(n[3],l,n[3]),a.clone(t,n[4]),a.add(n[4],r,n[4]),a.subtract(n[4],i,n[4]),a.subtract(n[4],l,n[4]),a.clone(t,n[5]),a.add(n[5],r,n[5]),a.subtract(n[5],i,n[5]),a.add(n[5],l,n[5]),a.clone(t,n[6]),a.add(n[6],r,n[6]),a.add(n[6],i,n[6]),a.subtract(n[6],l,n[6]),a.clone(t,n[7]),a.add(n[7],r,n[7]),a.add(n[7],i,n[7]),a.add(n[7],l,n[7]),n};var Zv=w;export{Zv as a};